local t=table.concat local f=select local X=string.byte local S=string.sub local U={"\065\066\067";"\065\066\120";"\065\066\067","\065\066\067";"\065\066\067","\065\066\120","\065\066\067","\065\066\120";"\065\066\067","\065\066\067","\065\066\067";"\065\066\067";"\065\066\067","\065\066\067";"\065\066\067","\065\066\067","\065\066\067","\065\066\067","\065\066\067","\065\066\067";"\065\066\067";"\065\066\067";"\065\115\066\120";"\065\066\067";"\065\066\067","\065\066\067","\065\066\067","\065\066\067";"\065\066\067";"\065\066\067","\065\066\067";"\065\115\066\120","\065\115\066\120";"\065\066\067","\065\066\067";"\065\066\067","\065\066\120","\065\066\067"}local function I(t,f,X)if X then local S=(t/2^(f-1))%2^(((X-1)-(f-1))+1)return S-S%1 else local X=2^(f-1)if t%(X+X)>=X then return 1 else return 0 end end end local function d(t)local f=1 local d local h local function T()local S=X(t,f,f)f=f+1 return S end local function k()local S,U,I,d=X(t,f,f+3)f=f+4 return((d*16777216+I*65536)+U*256)+S end local function e()return k()*4294967296+k()end local function s()local t,f=k(),k()if t+f==0 then return 0 else return((-2*I(f,32)+1)*2^(I(f,21,31)-1023))*((I(f,1,20)*4294967296.0+t)/4.5035996273705e+15+1)end end local function c(X)local U if X then U=S(t,f,(f+X)-1)f=f+X else X=d()if X==0 then return end U=S(t,f,(f+X)-1)f=f+X end return U end local function M()local t={}local f={}local X={}local d={Instr=t;Const=f;Proto=X,Lines={},Name=c(),FirstL=h();LastL=h(),Upvals=T(),Args=T();Vargs=T(),Stack=T()}if d.Name then d.Name=S(d.Name,1,-2)end for f=1,h(),1 do local X=k()local S=I(X,1,6)local d=U[S+1]local h={Enum=S,I(X,7,14)}if d=="\065\066\067"then h[2]=I(X,24,32)h[3]=I(X,15,23)elseif d=="\065\066\120"then h[2]=I(X,15,32)elseif d=="\065\115\066\120"then h[2]=I(X,15,32)-131071 end t[f]=h end for t=1,h(),1 do local X=T()local U if X==1 then U=T()~=0 elseif X==3 then U=s()elseif X==4 then U=S(c(),1,-2)end f[t-1]=U end for t=1,h(),1 do X[t-1]=M()end do local t=d.Lines for f=1,h(),1 do t[f]=k()end for t=1,h(),1 do c()k()k()end for t=1,h(),1 do c()end end return d end do assert(c(4)=="\027\076\117\097","\076\117\097 \098\121\116\101\099\111\100\101 \101\120\112\101\099\116\101\100\046")assert(T()==81,"\079\110\108\121 \076\117\097 \053\046\049 \105\115 \115\117\112\112\111\114\116\101\100\046")T()T()local t=T()local f=T()if t==4 then h=k elseif t==8 then h=e else error("\085\110\115\117\112\112\111\114\116\101\100 \098\121\116\101\099\111\100\101 \116\097\114\103\101\116 \112\108\097\116\102\111\114\109",2)end if f==4 then d=k elseif f==8 then d=e else error("\085\110\115\117\112\112\111\114\116\101\100 \098\121\116\101\099\111\100\101 \116\097\114\103\101\116 \112\108\097\116\102\111\114\109",2)end assert(c(3)=="\004\b\000","\085\110\115\117\112\112\111\114\116\101\100 \098\121\116\101\099\111\100\101 \116\097\114\103\101\116 \112\108\097\116\102\111\114\109")end return M()end local function h(...)return f("\035",...),{...}end local function T(X,S,U)local I=X.Instr local d=X.Const local k=X.Proto local e,s local c=1 local M,g local function B(f,X)if f==0 then e[X[1]]=e[X[2]]elseif f==1 then e[X[1]]=d[X[2]]elseif f==2 then e[X[1]]=X[2]~=0 if X[3]~=0 then c=c+1 end elseif f==3 then local t=e for f=X[1],X[2],1 do t[f]=nil end elseif f==4 then e[X[1]]=U[X[2]]elseif f==5 then e[X[1]]=S[d[X[2]]]elseif f==6 then local t=X[3]local f=e if t>255 then t=d[t-256]else t=f[t]end f[X[1]]=f[X[2]][t]elseif f==7 then S[d[X[2]]]=e[X[1]]elseif f==8 then U[X[2]]=e[X[1]]elseif f==9 then local t,f=X[2],X[3]local S=e if t>255 then t=d[t-256]else t=S[t]end if f>255 then f=d[f-256]else f=S[f]end S[X[1]][t]=f elseif f==10 then e[X[1]]={}elseif f==11 then local t=X[1]local f=X[2]local S=X[3]local U=e f=U[f]if S>255 then S=d[S-256]else S=U[S]end U[t+1]=f U[t]=f[S]elseif f==12 then local t=X[2]local f=X[3]local S,U=e,d if t>255 then t=d[t-256]else t=S[t]end if f>255 then f=d[f-256]else f=S[f]end S[X[1]]=t+f elseif f==13 then local t=X[2]local f=X[3]local S,U=e,d if t>255 then t=d[t-256]else t=S[t]end if f>255 then f=d[f-256]else f=S[f]end S[X[1]]=t-f elseif f==14 then local t=X[2]local f=X[3]local S,U=e,d if t>255 then t=d[t-256]else t=S[t]end if f>255 then f=d[f-256]else f=S[f]end S[X[1]]=t*f elseif f==15 then local t=X[2]local f=X[3]local S,U=e,d if t>255 then t=d[t-256]else t=S[t]end if f>255 then f=d[f-256]else f=S[f]end S[X[1]]=t/f elseif f==16 then local t=X[2]local f=X[3]local S,U=e,d if t>255 then t=d[t-256]else t=S[t]end if f>255 then f=d[f-256]else f=S[f]end S[X[1]]=t%f elseif f==17 then local t=X[2]local f=X[3]local S,U=e,d if t>255 then t=d[t-256]else t=S[t]end if f>255 then f=d[f-256]else f=S[f]end S[X[1]]=t^f elseif f==18 then e[X[1]]=-e[X[2]]elseif f==19 then e[X[1]]=not e[X[2]]elseif f==20 then e[X[1]]=#e[X[2]]elseif f==21 then local f=e local S=X[2]local U={e[S]}for t=S+1,X[3],1 do U[#U+1]=f[t]end e[X[1]]=t(U)elseif f==22 then c=c+X[2]elseif f==23 then local t=X[1]~=0 local f=X[2]local S=X[3]local U,I=e,d if f>255 then f=d[f-256]else f=U[f]end if S>255 then S=d[S-256]else S=U[S]end if(f==S)~=t then c=c+1 end elseif f==24 then local t=X[1]~=0 local f=X[2]local S=X[3]local U,I=e,d if f>255 then f=d[f-256]else f=U[f]end if S>255 then S=d[S-256]else S=U[S]end if(f<S)~=t then c=c+1 end elseif f==25 then local t=X[1]~=0 local f=X[2]local S=X[3]local U,I=e,d if f>255 then f=d[f-256]else f=U[f]end if S>255 then S=d[S-256]else S=U[S]end if(f<=S)~=t then c=c+1 end elseif f==26 then if not(not e[X[1]])==(X[3]==0)then c=c+1 end elseif f==27 then local t=e[X[2]]if not(not t)==(X[3]==0)then c=c else e[X[1]]=t end elseif f==28 then local t=X[1]local f=X[2]local S=X[3]local U=e local I,d local T,k I={}if f~=1 then if f~=0 then T=(t+f)-1 else T=s end k=0 for t=t+1,T,1 do k=k+1 I[k]=U[t]end T,d=h(U[t](unpack(I,1,T-t)))else T,d=h(U[t]())end s=t-1 if S~=1 then if S~=0 then T=(t+S)-2 else T=T+t end k=0 for t=t,T,1 do k=k+1 U[t]=d[k]end end elseif f==29 then local t=X[1]local f=X[2]local S=X[3]local U=e local I,d local h,T I={}if f~=1 then if f~=0 then h=(t+f)-1 else h=s end T=0 for t=t+1,h,1 do T=T+1 I[#I+1]=U[t]end d={U[t](unpack(I,1,h-t))}else d={U[t]()}end return true,d elseif f==30 then local t=X[1]local f=X[2]local S=e local U,I local d if f==1 then return true elseif f==0 then d=s else d=(t+f)-2 end I={}local h=0 for t=t,d,1 do h=h+1 I[h]=S[t]end return true,I elseif f==31 then local t=X[1]local f=e local S=f[t+2]local U=f[t]+S f[t]=U if S>0 then if U<=f[t+1]then c=c+X[2]f[t+3]=U end else if U>=f[t+1]then c=c+X[2]f[t+3]=U end end elseif f==32 then local t=X[1]local f=e f[t]=f[t]-f[t+2]c=c+X[2]elseif f==33 then local t=X[1]local f=X[2]local S=X[3]local U=e local I=t+2 local d={U[t](U[t+1],U[t+2])}for t=1,S,1 do e[I+t]=d[t]end if U[t+3]~=nil then U[t+2]=U[t+3]else c=c+1 end elseif f==34 then local t=X[1]local f=X[2]local S=X[3]local U=e if S==0 then error("\078\089\073\058 \101\120\116\101\110\100\101\100 \083\069\084\076\073\083\084")else local X=(S-1)*50 local I=U[t]if f==0 then f=s end for f=1,f,1 do I[X+f]=U[t+f]end end elseif f==35 then elseif f==36 then local t=k[X[2]]local f=I local d=e local h={}local s=setmetatable({},{__index=function(t,f)local X=h[f]return X[1][X[2]]end;__newindex=function(t,f,X)local S=h[f]S[1][S[2]]=X end})for t=1,t.Upvals,1 do local X=f[c]if X.Enum==0 then h[t-1]={d,X[2]}elseif X.Enum==4 then h[t-1]={U;X[2]}end c=c+1 end d[X[1]]=T(t,S,s)elseif f==37 then local t=X[1]local f=X[2]local S,U=e,M for f=t,t+(f>0 and f-1 or g),1 do S[f]=U[f-t]end end end local function N(t)local f=X.Name or"\067\111\100\101"local S=X.Lines[c]or"\063"local U=t:match("\094\046\043\058\037\115\042\040\046\043\041")or t error(string.format("\037\115 \040\037\115\041\058 \037\115",f,S,U),0)end local function K()local t=pcall local f=I local X,S,U,d while true do X=f[c]if not X then return U end c=c+1 d,S,U=t(B,X.Enum,X)if d then if S then return U end else N(S)break end end end return function(...)local t={}local X={}s=-1 e=setmetatable(t,{__index=X,__newindex=function(t,f,S)if f>s and S then s=f end X[f]=S end})local S={...}M={}g=f("\035",...)-1 c=1 for f=0,g,1 do t[f]=S[f+1]M[f]=S[f+1]end local U,I=pcall(K)if U then if I then return unpack(I)end return else N(I)end end end return function(t,f)local X=d(t)return T(X,f or getfenv(0)),X end
local Concat	= table.concat;
local Select	= select;
local _Byte		= string.byte;
local Sub		= string.sub;
local Opcode	= { -- Opcode types.
	'ABC',	'ABx',	'ABC',	'ABC';
	'ABC',	'ABx',	'ABC',	'ABx';
	'ABC',	'ABC',	'ABC',	'ABC';
	'ABC',	'ABC',	'ABC',	'ABC';
	'ABC',	'ABC',	'ABC',	'ABC';
	'ABC',	'ABC',	'AsBx',	'ABC';
	'ABC',	'ABC',	'ABC',	'ABC';
	'ABC',	'ABC',	'ABC',	'AsBx';
	'AsBx',	'ABC',	'ABC',	'ABC';
	'ABx',	'ABC';
};

-- rlbi author -> Rerumu (Shining_Diamando)

--[[
	Consider this a direct upgrade to the beauty that stravant left behind.
	This "new" version includes:
		* Almost complete rework (most things reworked from scratch)
		* Visible performance improvements
		* Upvalue error fixes
		* C Stack overflow fixes (most cases anyways)
		* Fixed missing "return" errors
		* Solved 0 const being treated as "1.1125369292536e-308"
		* A more readable format for easier editing of the code
--]]

--[[
	TODO LIST:
		* Fix tailcalls not properly working (and recursion in general)
		* Implement CLOSE (whatever it may do)
		* Figure out extended SETLIST (same as CLOSE)
		* Sometimes return doesn't work? Maybe it's just me.
--]]

-- 1 BYTE = 8 BITS; 4 byte instructions = 32 bit instructions.
local function gBit(Bit, Start, End) -- No tail-calls, yay.
	if End then -- Thanks to cntkillme for giving input on this shorter, better approach.
		local Res	= (Bit / 2 ^ (Start - 1)) % 2 ^ ((End - 1) - (Start - 1) + 1);

		return Res - Res % 1;
	else
		local Plc = 2 ^ (Start - 1);

		if (Bit % (Plc + Plc) >= Plc) then
			return 1; -- Check if within range.
		else
			return 0;
		end;
	end;
end;

local function GetMeaning(ByteString)
	local Pos	= 1;
	local gSizet;
	local gInt;

	local function gBits8() -- Get the next byte in the stream.
		local F	= _Byte(ByteString, Pos, Pos);

		Pos	= Pos + 1;

		return F;
	end;

	local function gBits32()
		local W, X, Y, Z	= _Byte(ByteString, Pos, Pos + 3);

		Pos	= Pos + 4;

		return (Z * 16777216) + (Y * 65536) + (X * 256) + W;
	end;

	local function gBits64()
		return gBits32() * 4294967296 + gBits32();
	end;

	local function gFloat() -- Besides the 0 check, this part remained mostly static.
		local A, B	= gBits32(), gBits32();

		if ((A + B) == 0) then
			return 0; -- Float 0 tends to be very messy, so this is a temp fix until I figure out what's up.
		else
			return (-2 * gBit(B, 32) + 1) * (2 ^ (gBit(B, 21, 31) - 1023)) * ((gBit(B, 1, 20) * (2^32) + A) / (2 ^ 52) + 1);
		end;
	end;

	local function gString(Len)
		local Str;

		if Len then
			Str	= Sub(ByteString, Pos, Pos + Len - 1);

			Pos = Pos + Len;
		else
			Len = gSizet();

			if (Len == 0) then return; end;

			Str	= Sub(ByteString, Pos, Pos + Len - 1);

			Pos = Pos + Len;
		end;

		return Str;
	end;

	local function ChunkDecode()
		local Instr	= {};
		local Const	= {};
		local Proto	= {};
		local Chunk	= {
			Instr	= Instr; -- Instructions
			Const	= Const; -- Constants
			Proto	= Proto; -- Prototypes
			Lines	= {}; -- Lines
			Name	= gString(); -- Grab name string.
			FirstL	= gInt(); -- First line.
			LastL	= gInt(); -- Last line.
			Upvals	= gBits8(); -- Upvalue count.
			Args	= gBits8(); -- Arg count.
			Vargs	= gBits8(); -- Vararg type.
			Stack	= gBits8(); -- Stack.
		};

		if Chunk.Name then
			Chunk.Name	= Sub(Chunk.Name, 1, -2);
		end;

		for Idx = 1, gInt() do -- Loading instructions to the chunk.
			local Data	= gBits32();
			local Opco	= gBit(Data, 1, 6);
			local Type	= Opcode[Opco + 1];
			local Inst	= {
				Enum	= Opco;
				gBit(Data, 7, 14); -- Register A.
			};

			if (Type == 'ABC') then -- Most common, basic instruction type.
				Inst[2]	= gBit(Data, 24, 32);
				Inst[3]	= gBit(Data, 15, 23);
			elseif (Type == 'ABx') then
				Inst[2]	= gBit(Data, 15, 32);
			elseif (Type == 'AsBx') then
				Inst[2]	= gBit(Data, 15, 32) - 131071;
			end;

			Instr[Idx]	= Inst;
		end;

		for Idx = 1, gInt() do -- Load constants.
			local Type	= gBits8();
			local Cons;

			if (Type == 1) then -- Boolean
				Cons	= (gBits8() ~= 0);
			elseif (Type == 3) then -- Float/Double
				Cons	= gFloat();
			elseif (Type == 4) then
				Cons	= Sub(gString(), 1, -2);
			end;

			Const[Idx - 1]	= Cons;
		end;

		for Idx = 1, gInt() do -- Nested function prototypes.
			Proto[Idx - 1]	= ChunkDecode();
		end;

		do -- Debugging
			local Lines	= Chunk.Lines;

			for Idx = 1, gInt() do
				Lines[Idx]	= gBits32();
			end;

			for Idx = 1, gInt() do -- Locals in stack.
				gString(); -- Name of local.
				gBits32(); -- Starting point.
				gBits32(); -- End point.
			end;

			for Idx = 1, gInt() do -- Upvalues.
				gString(); -- Name of upvalue.
			end;
		end;

		return Chunk; -- Finished chunk.
	end;

	do
		assert(gString(4) == "\27Lua", "Lua bytecode expected.");
		assert(gBits8() == 0x51, "Only Lua 5.1 is supported.");

		gBits8(); -- Probably version control.
		gBits8(); -- Is small endians.

		local IntSize	= gBits8(); -- Int size
		local Sizet		= gBits8(); -- size_t

		if (IntSize == 4) then
			gInt	= gBits32;
		elseif (IntSize == 8) then
			gInt	= gBits64;
		else
			error("Unsupported bytecode target platform", 2);
		end;

		if (Sizet == 4) then
			gSizet	= gBits32;
		elseif (Sizet == 8) then
			gSizet	= gBits64;
		else
			error("Unsupported bytecode target platform", 2);
		end;

		assert(gString(3) == "\4\8\0", "Unsupported bytecode target platform");
	end;

	return ChunkDecode();
end;

local function _Returns(...)
	return Select('#', ...), {...};
end;

local function Wrap(Chunk, Env, Upvalues)
	local Instr	= Chunk.Instr;
	local Const	= Chunk.Const;
	local Proto	= Chunk.Proto;

	local Stack, Top;
	local InstrPoint	= 1;

	local Vararg, Varargsz;

	local function COpcode(Enum, Inst) -- Opcodes re-implemented into a function for performance!
		if (Enum == 0) then -- MOVE
			Stack[Inst[1]]	= Stack[Inst[2]];
		elseif (Enum == 1) then -- LOADK
			Stack[Inst[1]]	= Const[Inst[2]];
		elseif (Enum == 2) then -- LOADBOOL
			Stack[Inst[1]]	= (Inst[2] ~= 0);

			if (Inst[3] ~= 0) then
				InstrPoint	= InstrPoint + 1;
			end;
		elseif (Enum == 3) then -- LOADNIL
			local Stk	= Stack; -- Since this moves it down.

			for Idx = Inst[1], Inst[2] do
				Stk[Idx]	= nil;
			end;
		elseif (Enum == 4) then -- GETUPVAL
			Stack[Inst[1]]	= Upvalues[Inst[2]];
		elseif (Enum == 5) then -- GETGLOBAL
			Stack[Inst[1]]	= Env[Const[Inst[2]]];
		elseif (Enum == 6) then -- GETTABLE
			local C		= Inst[3];
			local Stk	= Stack;

			if (C > 255) then
				C	= Const[C - 256];
			else
				C	= Stk[C];
			end;

			Stk[Inst[1]]	= Stk[Inst[2]][C];
		elseif (Enum == 7) then -- SETGLOBAL
			Env[Const[Inst[2]]]	= Stack[Inst[1]];
		elseif (Enum == 8) then -- SETUPVAL
			Upvalues[Inst[2]]	= Stack[Inst[1]];
		elseif (Enum == 9) then -- SETTABLE
			local B, C	= Inst[2], Inst[3];
			local Stk	= Stack;

			if (B > 255) then
				B	= Const[B - 256];
			else
				B	= Stk[B];
			end;

			if (C > 255) then
				C	= Const[C - 256];
			else
				C	= Stk[C];
			end;

			Stk[Inst[1]][B]	= C;
		elseif (Enum == 10) then -- NEWTABLE
			Stack[Inst[1]]	= {};
		elseif (Enum == 11) then -- SELF
			local A		= Inst[1];
			local B		= Inst[2];
			local C		= Inst[3];
			local Stk	= Stack;

			B = Stk[B];

			if (C > 255) then
				C	= Const[C - 256];
			else
				C	= Stk[C];
			end;

			Stk[A + 1]	= B;
			Stk[A]		= B[C];
		elseif (Enum == 12) then -- ADD
			local B	= Inst[2];
			local C	= Inst[3];
			local Stk, Con	= Stack, Const;

			if (B > 255) then
				B	= Const[B - 256];
			else
				B	= Stk[B];
			end;

			if (C > 255) then
				C	= Const[C - 256];
			else
				C	= Stk[C];
			end;

			Stk[Inst[1]]	= B + C;
		elseif (Enum == 13) then -- SUB
			local B	= Inst[2];
			local C	= Inst[3];
			local Stk, Con	= Stack, Const;

			if (B > 255) then
				B	= Const[B - 256];
			else
				B	= Stk[B];
			end;

			if (C > 255) then
				C	= Const[C - 256];
			else
				C	= Stk[C];
			end;

			Stk[Inst[1]]	= B - C;
		elseif (Enum == 14) then -- MUL
			local B	= Inst[2];
			local C	= Inst[3];
			local Stk, Con	= Stack, Const;

			if (B > 255) then
				B	= Const[B - 256];
			else
				B	= Stk[B];
			end;

			if (C > 255) then
				C	= Const[C - 256];
			else
				C	= Stk[C];
			end;

			Stk[Inst[1]]	= B * C;
		elseif (Enum == 15) then -- DIV
			local B	= Inst[2];
			local C	= Inst[3];
			local Stk, Con	= Stack, Const;

			if (B > 255) then
				B	= Const[B - 256];
			else
				B	= Stk[B];
			end;

			if (C > 255) then
				C	= Const[C - 256];
			else
				C	= Stk[C];
			end;

			Stk[Inst[1]]	= B / C;
		elseif (Enum == 16) then -- MOD
			local B	= Inst[2];
			local C	= Inst[3];
			local Stk, Con	= Stack, Const;

			if (B > 255) then
				B	= Const[B - 256];
			else
				B	= Stk[B];
			end;

			if (C > 255) then
				C	= Const[C - 256];
			else
				C	= Stk[C];
			end;

			Stk[Inst[1]]	= B % C;
		elseif (Enum == 17) then -- POW
			local B	= Inst[2];
			local C	= Inst[3];
			local Stk, Con	= Stack, Const;

			if (B > 255) then
				B	= Const[B - 256];
			else
				B	= Stk[B];
			end;

			if (C > 255) then
				C	= Const[C - 256];
			else
				C	= Stk[C];
			end;

			Stk[Inst[1]]	= B ^ C;
		elseif (Enum == 18) then -- UNM
			Stack[Inst[1]]	= -Stack[Inst[2]];
		elseif (Enum == 19) then -- NOT
			Stack[Inst[1]]	= (not Stack[Inst[2]]);
		elseif (Enum == 20) then -- LEN
			Stack[Inst[1]]	= #Stack[Inst[2]];
		elseif (Enum == 21) then -- CONCAT
			local Stk	= Stack;
			local B		= Inst[2];
			local K		= {Stack[B]};

			for Idx = B + 1, Inst[3] do
				K[#K + 1]	= Stk[Idx];
			end;

			Stack[Inst[1]]	= Concat(K);
		elseif (Enum == 22) then -- JUMP
			InstrPoint	= InstrPoint + Inst[2];
		elseif (Enum == 23) then -- EQ
			local A	= Inst[1] ~= 0;
			local B	= Inst[2];
			local C	= Inst[3];
			local Stk, Con	= Stack, Const;

			if (B > 255) then
				B	= Const[B - 256];
			else
				B	= Stk[B];
			end;

			if (C > 255) then
				C	= Const[C - 256];
			else
				C	= Stk[C];
			end;

			if (B == C) ~= A then
				InstrPoint	= InstrPoint + 1;
			end;
		elseif (Enum == 24) then -- LT
			local A	= Inst[1] ~= 0;
			local B	= Inst[2];
			local C	= Inst[3];
			local Stk, Con	= Stack, Const;

			if (B > 255) then
				B	= Const[B - 256];
			else
				B	= Stk[B];
			end;

			if (C > 255) then
				C	= Const[C - 256];
			else
				C	= Stk[C];
			end;

			if (B < C) ~= A then
				InstrPoint	= InstrPoint + 1;
			end;
		elseif (Enum == 25) then -- LE
			local A	= Inst[1] ~= 0;
			local B	= Inst[2];
			local C	= Inst[3];
			local Stk, Con	= Stack, Const;

			if (B > 255) then
				B	= Const[B - 256];
			else
				B	= Stk[B];
			end;

			if (C > 255) then
				C	= Const[C - 256];
			else
				C	= Stk[C];
			end;

			if (B <= C) ~= A then
				InstrPoint	= InstrPoint + 1;
			end;
		elseif (Enum == 26) then -- TEST
			if (not not Stack[Inst[1]]) == (Inst[3] == 0) then
				InstrPoint	= InstrPoint + 1;
			end;
		elseif (Enum == 27) then -- TESTSET
			local B	= Stack[Inst[2]];

			if (not not B) == (Inst[3] == 0) then
				InstrPoint	= InstrPoint;
			else
				Stack[Inst[1]] = B;
			end;
		elseif (Enum == 28) then -- CALL
			local A	= Inst[1];
			local B	= Inst[2];
			local C	= Inst[3];
			local Stk	= Stack;
			local Args, Results;
			local Limit, Loop;

			Args	= {};

			if (B ~= 1) then
				if (B ~= 0) then
					Limit = A + B - 1;
				else
					Limit = Top;
				end;

				Loop	= 0;

				for Idx = A + 1, Limit do
					Loop = Loop + 1;

					Args[Loop] = Stk[Idx];
				end;

				Limit, Results = _Returns(Stk[A](unpack(Args, 1, Limit - A)));
			else
				Limit, Results = _Returns(Stk[A]());
			end;

			Top = A - 1;

			if (C ~= 1) then
				if (C ~= 0) then
					Limit = A + C - 2;
				else
					Limit = Limit + A;
				end;

				Loop	= 0;

				for Idx = A, Limit do
					Loop = Loop + 1;

					Stk[Idx] = Results[Loop];
				end;
			end;
		elseif (Enum == 29) then -- TAILCALL
			local A	= Inst[1];
			local B	= Inst[2];
			local C	= Inst[3];
			local Stk	= Stack;
			local Args, Results;
			local Limit, Loop;

			Args = {};

			if (B ~= 1) then
				if (B ~= 0) then
					Limit = A + B - 1;
				else
					Limit = Top;
				end

				Loop = 0;

				for Idx = A + 1, Limit do
					Loop = Loop + 1;

					Args[#Args + 1] = Stk[Idx];
				end

				Results = {Stk[A](unpack(Args, 1, Limit - A))};
			else
				Results = {Stk[A]()};
			end;

			return true, Results;
		elseif (Enum == 30) then -- RETURN
			local A	= Inst[1]; -- TODO: Work out why RETURN doesn't always get called.
			local B	= Inst[2];
			local Stk	= Stack;
			local Loop, Output;
			local Limit;

			if (B == 1) then
				return true;
			elseif (B == 0) then
				Limit	= Top;
			else
				Limit	= A + B - 2;
			end;

			Output = {};

			local Loop	= 0;

			for Idx = A, Limit do
				Loop	= Loop + 1;

				Output[Loop] = Stk[Idx];
			end;

			return true, Output;
		elseif (Enum == 31) then -- FORLOOP
			local A		= Inst[1];
			local Stk	= Stack;

			local Step	= Stk[A + 2];
			local Index	= Stk[A] + Step;

			Stk[A]	= Index;

			if (Step > 0) then
				if Index <= Stk[A + 1] then
					InstrPoint	= InstrPoint + Inst[2];

					Stk[A + 3] = Index;
				end;
			else
				if Index >= Stk[A + 1] then
					InstrPoint	= InstrPoint + Inst[2];

					Stk[A + 3] = Index;
				end
			end
		elseif (Enum == 32) then -- FORPREP
			local A		= Inst[1];
			local Stk	= Stack;

			Stk[A]	= Stk[A] - Stk[A + 2];

			InstrPoint	= InstrPoint + Inst[2];
		elseif (Enum == 33) then -- TFORLOOP
			local A		= Inst[1];
			local B		= Inst[2];
			local C		= Inst[3];
			local Stk	= Stack;

			local Offset	= A + 2;
			local Result	= {Stk[A](Stk[A + 1], Stk[A + 2])};

			for Idx = 1, C do
				Stack[Offset + Idx] = Result[Idx];
			end;

			if (Stk[A + 3] ~= nil) then
				Stk[A + 2]	= Stk[A + 3];
			else
				InstrPoint	= InstrPoint + 1;
			end;
		elseif (Enum == 34) then -- SETLIST
			local A		= Inst[1];
			local B		= Inst[2];
			local C		= Inst[3];
			local Stk	= Stack;

			if (C == 0) then
				error("NYI: extended SETLIST"); -- TODO: Will research and implement if I can find what it's for.
			else
				local Offset	= (C - 1) * 50;
				local T			= Stk[A]; -- Assuming T is the newly created table.

				if (B == 0) then
					B	= Top;
				end;

				for Idx = 1, B do
					T[Offset + Idx] = Stk[A + Idx];
				end;
			end;
		elseif (Enum == 35) then -- CLOSE
			-- TODO: Will also implement once I find out what it's for.
		elseif (Enum == 36) then -- CLOSURE
			local Proto	= Proto[Inst[2]];
			local Instr = Instr;
			local Stk	= Stack;

			local Indexes	= {};
			local NewUvals	= setmetatable({}, {
					__index = function(_, Key)
						local Val	= Indexes[Key];

						return Val[1][Val[2]];
					end,
					__newindex = function(_, Key, Value)
						local Val	= Indexes[Key];

						Val[1][Val[2]]	= Value;
					end;
				}
			);

			for Idx = 1, Proto.Upvals do
				local Mvm	= Instr[InstrPoint];

				if (Mvm.Enum == 0) then -- MOVE
					Indexes[Idx - 1] = {Stk, Mvm[2]};
				elseif (Mvm.Enum == 4) then -- GETUPVAL
					Indexes[Idx - 1] = {Upvalues, Mvm[2]};
				end;

				InstrPoint	= InstrPoint + 1;
			end;

			Stk[Inst[1]]	= Wrap(Proto, Env, NewUvals);
		elseif (Enum == 37) then -- VARARG
			local A	= Inst[1];
			local B	= Inst[2];
			local Stk, Vararg	= Stack, Vararg;

			for Idx = A, A + (B > 0 and B - 1 or Varargsz) do
				Stk[Idx]	= Vararg[Idx - A];
			end;
		end;
	end;

	local function OnError(Err) -- Handle your errors in whatever way.
		local Name	= Chunk.Name or 'Code';
		local Line	= Chunk.Lines[InstrPoint] or '?';
		local Err	= Err:match'^.+:%s*(.+)' or Err;

		error(string.format('%s (%s): %s', Name, Line, Err), 0);
	end;

	local function Loop()
		local pcall	= pcall;
		local Instr	= Instr;
		local Inst, A, B, R;

		while true do
			Inst	= Instr[InstrPoint];

			if (not Inst) then
				return B;
			end;

			InstrPoint	= InstrPoint + 1;

			R, A, B	= pcall(COpcode, Inst.Enum, Inst);

			if R then
				if A then
					return B;
				end;
			else
				OnError(A);

				break;
			end;
		end;
	end;

	return function(...) -- Returned function to run bytecode chunk (Don't be stupid, you can't setfenv this to work your way).
		local LStack	= {};
		local GStack	= {};

		Top	= -1;

		Stack	= setmetatable(LStack, {
			__index		= GStack;
			__newindex	= function(_, Key, Value)
				if (Key > Top) and Value then
					Top	= Key;
				end;

				GStack[Key]	= Value;
			end;
		});

		local Args	= {...};

		Vararg		= {};
		Varargsz	= Select('#', ...) - 1;
		InstrPoint	= 1;

		for Idx = 0, Varargsz do
			LStack[Idx] = Args[Idx + 1];
			Vararg[Idx] = Args[Idx + 1];
		end;

		local A, B		= pcall(Loop); -- What *would* be the difference between routining and pcalling this?

		if A then -- We're always expecting this to come out true (because errorless code)
			if B then -- So I flipped the conditions.
				return unpack(B);
			end;

			return;
		else
			OnError(B);
		end;
	end;
end;

return function(BCode, Env) -- lua_function LoadBytecode (string BCode, table Env)
	local Buffer	= GetMeaning(BCode);
	
	return Wrap(Buffer, Env or getfenv(0)), Buffer;
end;