// PP_n.c
// Generated by decompiling PP.EXE
// using Reko decompiler version 0.11.6.0.

#include "PP.h"

struct seg0800_t * g_ptr8000 = &g_tFFFF83BA; // 00008000
// 0800:0150: void fn0800-0150()
// Called from:
//      fn0800-8B0D
void fn0800-0150()
{
	selector seg0800;
	fn0800-01E6(&Eq_n::t2714, &Eq_n::t2714, seg0800->ptr025A);
}

// 0800:0163: void fn0800-0163()
// Called from:
//      fn0800-8B0D
void fn0800-0163()
{
}

// 0800:0164: void fn0800-0164(Stack Eq_n bArg02)
// Called from:
//      fn0800-8B0D
void fn0800-0164(Eq_n bArg02)
{
	msdos_terminate(bArg02);
}

// 0800:0176: void fn0800-0176(Register (ptr16 Eq_n) ds)
void fn0800-0176(struct Eq_n * ds)
{
	ds->dw005B = msdos_get_interrupt_vector(0x00);
	ds->dw005F = msdos_get_interrupt_vector(0x04);
	ds->dw0063 = msdos_get_interrupt_vector(0x05);
	ds->dw0067 = msdos_get_interrupt_vector(0x06);
	struct Eq_n * cs;
	msdos_set_interrupt_vector(0x00, &cs->t016D);
}

// 0800:01B9: Register byte fn0800-01B9(Register Eq_n ds, Register out word16 dxOut)
// Called from:
//      fn0800-8B0D
byte fn0800-01B9(Eq_n ds, word16 & dxOut)
{
	msdos_set_interrupt_vector(0x00, Mem7[ds:0x5B:segptr32]);
	msdos_set_interrupt_vector(0x04, Mem16[ds:0x5F:segptr32]);
	msdos_set_interrupt_vector(0x05, Mem25[ds:99:segptr32]);
	<anonymous> * ds_dx_n = Mem34[ds:0x67:segptr32];
	msdos_set_interrupt_vector(0x06, ds_dx_n);
	dxOut = (word16) ds_dx_n;
	return 0x25;
}

// 0800:01E6: void fn0800-01E6(Register (memptr (ptr16 Eq_n) Eq_n) si, Register (memptr (ptr16 Eq_n) Eq_n) di, Register (ptr16 Eq_n) es)
// Called from:
//      fn0800-0150
void fn0800-01E6(struct Eq_n Eq_n::* si, struct Eq_n Eq_n::* di, struct Eq_n * es)
{
	while (true)
	{
		cu8 ah_n;
		if (si != &Eq_n::t26FC)
			ah_n = 0x00;
		else
			ah_n = ~0x00;
		struct Eq_n Eq_n::* dx_n = di;
		struct Eq_n Eq_n::* bx_n;
		for (bx_n = si; bx_n != di; ++bx_n)
		{
			if ((es->*bx_n).b0000 != ~0x00)
			{
				bool v18_n;
				if (si != &Eq_n::t26FC)
					v18_n = ah_n > (es->*bx_n).b0001;
				else
					v18_n = (es->*bx_n).b0001 > ah_n;
				if (!v18_n)
				{
					ah_n = (es->*bx_n).b0001;
					dx_n = bx_n;
				}
			}
		}
		if (dx_n == di)
			break;
		(es->*dx_n).b0000 = ~0x00;
		if ((es->*dx_n).b0000 != 0x00)
			(es->*dx_n).t0002.u0();
		else
		{
			selector seg0800;
			(seg0800->*((es->*dx_n).t0002).u1)();
		}
	}
}

// 0800:023D: void fn0800-023D(Sequence (ptr32 char) ds_dx, Register word16 cx)
void fn0800-023D(char * ds_dx, word16 cx)
{
	word16 ax_n;
	msdos_write_file(0x02, cx, ds_dx, out ax_n);
}

struct Eq_n * g_ptr025A = null; // 0800:025A
// 0800:025E: void main(Register Eq_n ds)
void main(Eq_n ds)
{
	Eq_n cx_n;
	word16 cx_n;
	word16 cx_n;
	Eq_n cx_n;
	Eq_n ds_n;
	Eq_n bx_n;
	Eq_n dx_n;
	Mem15[ds:0x2A27:word16] = 0x01;
	Mem16[ds:11853:word16] = 0x00;
	Mem17[ds:0x2A1F:word16] = 0x00;
	Mem18[ds:11855:word16] = 0x00;
	Mem19[ds:10781:word16] = 0x00;
	Mem20[ds:10775:word16] = 0x00;
	Mem21[ds:10779:word16] = 0x00;
	Mem22[ds:0x2A11:word16] = 0x00;
	Mem23[ds:0x2A0F:word16] = 0x00;
	Mem24[ds:0x2A0D:word16] = 0x00;
	Mem25[ds:0x2A0B:word16] = 0x3000;
	Mem26[ds:11825:word16] = 0x8000;
	Mem27[ds:0x2E2F:word16] = 0x1000;
	Mem28[ds:0x2A21:word16] = 0x01;
	Mem29[ds:10741:word16] = 0x00;
	Mem30[ds:0x29F3:word16] = 0x00;
	Mem31[ds:10737:word16] = 0x00;
	Mem32[ds:0x29EF:word16] = 0x00;
	Mem33[ds:10771:word16] = 0x00;
	Mem34[ds:0x2A23:word16] = 0x01;
	Eq_n cx_n = fn0800-2C9A(ds, out dx_n, out bx_n);
	Eq_n di_n;
	fn0800_B2EF(cx_n, dx_n, bx_n, ds, SEQ(ds, 2024), out di_n);
	fn0800-0402(cx_n, dx_n, bx_n, ds);
	struct Eq_n Eq_n::* bp_n = fn0800-0541(di_n, ds, out ds_n);
	Eq_n sp_n;
	sp_n.u0 = <invalid>;
	selector ss;
	(ss->*((word32) sp_n - 2)).u0 = 0x01;
	(ss->*((word32) sp_n - 4)).u0 = 0x01;
	fn0800-2DBF(ds_n, ss->*((word32) sp_n - 4), ss->*((word32) sp_n - 2));
	(ss->*((word32) sp_n - 2)).u0 = 0x00;
	(ss->*((word32) sp_n - 4)).u0 = 0x00;
	word32 dx_ax_n = fn0800-9764(ds_n, ss->*((word32) sp_n - 4), out cx_n);
	Eq_n dx_n;
	dx_n.u3 = SLICE(dx_ax_n, word16, 16);
	(ss->*bp_n).tFFFFFFFE.u2 = (uint16) dx_n;
	(ss->*bp_n).tFFFFFFFC.u2 = (uint16) (word16) dx_ax_n;
	Eq_n sp_n = sp_n;
	Eq_n bx_n = Mem117[ds_n:0x2A25:word16];
	if (bx_n <= 0x08)
	{
		switch (bx_n)
		{
		case 0x00:
			ds_n = fn0800-0DE8(cx_n, dx_n, ds_n);
			break;
		case 0x01:
		case 0x02:
			ds_n = fn0800-112D(cx_n, dx_n, ds_n);
			break;
		case 0x03:
		case 0x04:
			bp_n = fn0800-12E2(cx_n, dx_n, ds_n, out ds_n);
			sp_n.u0 = <invalid>;
			break;
		case 0x05:
			bp_n = fn0800-18D9(cx_n, dx_n, ds_n, out ds_n);
			sp_n.u0 = <invalid>;
			break;
		case 0x06:
		case 0x07:
		case 0x08:
			bp_n = fn0800-19EE(cx_n, dx_n, ds_n, out ds_n);
			sp_n.u0 = <invalid>;
			break;
		}
	}
	struct Eq_n Eq_n::* sp_n = sp_n - 2;
	(ss->*sp_n).w0000 = 0x00;
	(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x00;
	word32 dx_ax_n = fn0800-9764(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out cx_n) - ((ss->*bp_n).tFFFFFFFC).u3;
	(ss->*bp_n).tFFFFFFFE.u2 = SLICE(dx_ax_n, word16, 16);
	(ss->*bp_n).tFFFFFFFC.u2 = (uint16) (word16) dx_ax_n;
	Mem245[ss:sp_n + 0x00:word16] = Mem242[ds_n:10737:word16];
	Mem248[ss:sp_n + -2:word16] = Mem245[ds_n:0x29EF:word16];
	Mem251[ss:sp_n + -4:word16] = Mem248[ds_n:10741:word16];
	Mem254[ss:sp_n + -6:word16] = Mem251[ds_n:0x29F3:word16];
	Eq_n ax_n = fn0800-0B79((ss->*sp_n).tFFFFFFFA.u3, (ss->*sp_n).tFFFFFFFE.u3);
	(ss->*sp_n).w0000 = 0x00;
	(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x3C;
	(ss->*sp_n).tFFFFFFFC.u2 = (ss->*bp_n).tFFFFFFFE.u2;
	(ss->*sp_n).tFFFFFFFA.u2 = (ss->*bp_n).tFFFFFFFC.u2;
	Eq_n dx_ax_n = fn0800-8BCA((ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3);
	(ss->*sp_n).tFFFFFFF8.u2 = SLICE(dx_ax_n, word16, 16);
	(ss->*sp_n).wFFFFFFF6 = (word16) dx_ax_n;
	(ss->*sp_n).wFFFFFFF4 = 0x00;
	(ss->*sp_n).wFFFFFFF2 = 0x3C;
	(ss->*sp_n).wFFFFFFF0 = 0x00;
	(ss->*sp_n).wFFFFFFEE = 0x0E10;
	(ss->*sp_n).tFFFFFFEC.u2 = (ss->*bp_n).tFFFFFFFE.u2;
	(ss->*sp_n).tFFFFFFEA.u2 = (ss->*bp_n).tFFFFFFFC.u2;
	Eq_n dx_ax_n = fn0800-8BCA((ss->*sp_n).tFFFFFFE8.u3, (ss->*sp_n).tFFFFFFEC.u3);
	(ss->*sp_n).tFFFFFFE8.u2 = SLICE(dx_ax_n, word16, 16);
	(ss->*sp_n).wFFFFFFE6 = (word16) dx_ax_n;
	int32 dx_ax_n = fn0800-8BBB((ss->*sp_n).tFFFFFFE4.u3, (ss->*sp_n).tFFFFFFE8.u3, out cx_n);
	(ss->*sp_n).tFFFFFFE4.u2 = SLICE(dx_ax_n, word16, 16);
	(ss->*sp_n).wFFFFFFE2 = (word16) dx_ax_n;
	(ss->*sp_n).wFFFFFFE0 = 0x00;
	(ss->*sp_n).wFFFFFFDE = 0x0E10;
	(ss->*sp_n).wFFFFFFDC = 0x00;
	(ss->*sp_n).wFFFFFFDA = 0x5180;
	(ss->*sp_n).tFFFFFFD8.u2 = (ss->*bp_n).tFFFFFFFE.u2;
	(ss->*sp_n).tFFFFFFD6.u2 = (ss->*bp_n).tFFFFFFFC.u2;
	Eq_n dx_ax_n = fn0800-8BCA((ss->*sp_n).tFFFFFFD4.u3, (ss->*sp_n).tFFFFFFD8.u3);
	(ss->*sp_n).tFFFFFFD4.u2 = SLICE(dx_ax_n, word16, 16);
	(ss->*sp_n).wFFFFFFD2 = (word16) dx_ax_n;
	int32 dx_ax_n = fn0800-8BBB((ss->*sp_n).tFFFFFFD0.u3, (ss->*sp_n).tFFFFFFD4.u3, out cx_n);
	(ss->*sp_n).tFFFFFFD0.u2 = SLICE(dx_ax_n, word16, 16);
	(ss->*sp_n).wFFFFFFCE = (word16) dx_ax_n;
	(ss->*sp_n).wFFFFFFCC = (uint32) ax_n % 100;
	uint32 dx_ax_n = (uint32) ax_n;
	(ss->*sp_n).wFFFFFFCA = dx_ax_n /u 100;
	Mem405[ss:sp_n + -56:word16] = Mem402[ds_n:10737:word16];
	Mem408[ss:sp_n + -58:word16] = Mem405[ds_n:0x29EF:word16];
	Mem411[ss:sp_n + -60:word16] = Mem408[ds_n:10741:word16];
	Mem414[ss:sp_n + -62:word16] = Mem411[ds_n:0x29F3:word16];
	(ss->*sp_n).tFFFFFFC0.u2 = (uint16) ds_n;
	(ss->*sp_n).wFFFFFFBE = 1500;
	(ss->*sp_n).wFFFFFFBC = 0x08;
	Mem425[ss:sp_n + -70:word16] = Mem422[ds_n:10771:word16];
	(ss->*sp_n).tFFFFFFB8.u2 = (uint16) ds_n;
	(ss->*sp_n).tFFFFFFB6.u2 = (uint16) 2027;
	word16 di_n;
	fn0800_B2EF(cx_n, dx_ax_n % 100, 100, ds_n, (ss->*sp_n).tFFFFFFB6.u3, out di_n);
}

// 0800:0402: void fn0800-0402(Register Eq_n cx, Register Eq_n dx, Register Eq_n bx, Register Eq_n ds)
// Called from:
//      main
void fn0800-0402(Eq_n cx, Eq_n dx, Eq_n bx, Eq_n ds)
{
	Eq_n bx_n;
	Eq_n dx_n;
	byte cl_n;
	word16 cx_n;
	if (Mem10[ds:0x2A27:word16] == Mem10[ds:9882:word16])
	{
		word16 di_n;
		fn0800-0DCE(cx, dx, bx, ds, out di_n);
	}
	Eq_n es_bx_n = Mem10[ds:9884:segptr32];
	struct Eq_n * es_n = SLICE(es_bx_n, selector, 16);
	union Eq_n Eq_n::* bx_n = SLICE(es_bx_n, word16, 0) + (Mem10[ds:0x2A27:word16] << 0x02);
	byte ch_n = SLICE(cx_n, byte, 8);
	if (fn0800_BFC7((es_n->*bx_n).u3, out cx_n) > 0x01)
	{
		Eq_n es_bx_n = Mem44[ds:9884:segptr32];
		struct Eq_n * es_n = SLICE(es_bx_n, selector, 16);
		union Eq_n Eq_n::* bx_n = SLICE(es_bx_n, word16, 0) + (Mem44[ds:0x2A27:word16] << 0x02);
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		word16 si_n;
		word16 di_n;
		fn0800-0D24(ds, 0x01, (es_n->*bx_n).u3, out cx_n, out dx_n, out bx_n, out si_n, out di_n, out ds);
		ch_n = SLICE(cx_n, byte, 8);
	}
	Eq_n ax_n = fn0800-0C29(ds, SEQ(ds, 0x0829), Mem89[ds:Mem89[ds:9884:word16][Mem89[ds:0x2A27:word16] * 0x04] + 0x00:byte], out cl_n, out dx_n, out bx_n);
	Mem123[ds:0x2A25:word16] = ax_n;
	Eq_n cx_n = SEQ(ch_n, cl_n);
	if (ax_n >= 0x09)
	{
		Eq_n es_bx_n = Mem123[ds:9884:segptr32];
		struct Eq_n * es_n = SLICE(es_bx_n, selector, 16);
		union Eq_n Eq_n::* bx_n = SLICE(es_bx_n, word16, 0) + (Mem123[ds:0x2A27:word16] << 0x02);
		word16 si_n;
		word16 di_n;
		fn0800-0D24(ds, 0x01, (es_n->*bx_n).u3, out cx_n, out dx_n, out bx_n, out si_n, out di_n, out ds);
	}
	Mem161[ds:0x2A27:word16] = Mem159[ds:0x2A27:word16] + 0x01;
	if (Mem161[ds:0x2A25:word16] > 0x02)
	{
		if (Mem161[ds:0x2A27:word16] == Mem161[ds:9882:word16])
		{
			word16 di_n;
			fn0800-0DCE(cx_n, dx_n, bx_n, ds, out di_n);
		}
		ui16 ax_n = Mem161[ds:0x2A27:word16];
		Mem188[ds:0x2A27:word16] = Mem161[ds:0x2A27:word16] + 0x01;
		Eq_n es_bx_n = Mem188[ds:9884:segptr32];
		struct Eq_n * es_n = SLICE(es_bx_n, selector, 16);
		union Eq_n Eq_n::* bx_n = (word16) es_bx_n + (ax_n << 0x02);
		fn0800_BF9E(SEQ(ds, 0x4348), (es_n->*bx_n).u3);
		fn0800-0C6C(ds, SEQ(ds, 0x4348));
		byte Eq_n::* di_n = 0x4348;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (ds->*di_n != 0x00)
				break;
		}
		byte Eq_n::* di_n = di_n - 0x01;
		word16 cx_n = ~cx_n;
		bool v41_n = di_n == 0x00;
		while (cx_n != 0x00)
		{
			v41_n = ds->*di_n == 0x2E;
			--di_n;
			--cx_n;
			if (ds->*di_n != 0x2E)
				break;
		}
		if (!v41_n)
			di_n = ~0x00;
		Eq_n di_n = di_n + 1;
		byte Eq_n::* di_n = 0x4348;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (ds->*di_n != 0x00)
				break;
		}
		word16 cx_n = ~cx_n;
		Eq_n di_n = di_n - cx_n;
		bool v45_n = di_n == 0x00;
		while (cx_n != 0x00)
		{
			v45_n = ds->*di_n == 0x5C;
			di_n = (word16) di_n + 1;
			--cx_n;
			if (ds->*di_n != 0x5C)
				break;
		}
		if (!v45_n)
			di_n.u0 = 0x01;
		if (di_n <= di_n - 0x01)
		{
			byte Eq_n::* di_n = 0x4348;
			word16 cx_n = ~0x00;
			while (cx_n != 0x00)
			{
				++di_n;
				--cx_n;
				if (ds->*di_n != 0x00)
					break;
			}
			memcpy(di_n - 0x01, *((word32) ds + 0x0833), 0x05);
		}
		Mem404[ds:10777:word16] = 0x01;
	}
}

// 0800:0541: Register word16 fn0800-0541(Register Eq_n di, Register Eq_n ds, Register out Eq_n dsOut)
// Called from:
//      main
word16 fn0800-0541(Eq_n di, Eq_n ds, union Eq_n & dsOut)
{
	selector ss;
	word16 bx_n;
	Eq_n dx_n;
	byte cl_n;
	word16 bx_n;
	Eq_n dx_n;
	byte cl_n;
	mp16 fp;
	struct Eq_n Eq_n::* bp_n = fp - 2;
	ui16 ax_n = Mem15[ds:0x2A27:word16];
	if (ax_n != Mem15[ds:9882:word16])
	{
		Eq_n ptrLoc06_n;
		Eq_n ptrLoc06;
		if (Mem15[ds:Mem15[ds:9884:word16][ax_n * 0x04] + 0x00:byte] == 0x2D)
			ptrLoc06_n = ptrLoc06;
		else
		{
			if (Mem15[ds:Mem15[ds:9884:word16][Mem15[ds:0x2A27:word16] * 0x04] + 0x00:byte] != 0x2F)
			{
				dsOut = ds;
				word16 bp;
				return bp;
			}
			ptrLoc06_n = ptrLoc06;
		}
		while (Mem48[ds:Mem48[ds:9884:word16][Mem48[ds:0x2A27:word16] * 0x04] + 0x00:byte] == 0x2D || Mem48[ds:Mem48[ds:9884:word16][Mem48[ds:0x2A27:word16] * 0x04] + 0x00:byte] == 0x2F)
		{
			Eq_n ax_n = fn0800-0C29(ds, SEQ(ds, 0x0838), Mem48[ds:Mem48[ds:9884:word16][Mem48[ds:0x2A27:word16] * 0x04] + 1:byte], out cl_n, out dx_n, out bx_n);
			Eq_n si_n = ax_n;
			if (ax_n >= 11)
			{
				Eq_n es_bx_n = Mem366[ds:9884:segptr32];
				struct Eq_n * es_n = SLICE(es_bx_n, selector, 16);
				union Eq_n Eq_n::* bx_n = SLICE(es_bx_n, word16, 0) + (Mem366[ds:0x2A27:word16] << 0x02);
				word16 cx_n;
				word16 bx_n;
				fn0800-0D24(ds, 0x02, (es_n->*bx_n).u3, out cx_n, out dx_n, out bx_n, out si_n, out di, out ds);
			}
			Eq_n ptrLoc06_n;
			if (si_n >= 0x06)
				ptrLoc06_n = ptrLoc06_n;
			else
			{
				Eq_n es_bx_n = Mem417[ds:9884:segptr32];
				struct Eq_n * es_n = SLICE(es_bx_n, selector, 16);
				Eq_n bx_n = SLICE(es_bx_n, word16, 0) + (Mem417[ds:0x2A27:word16] << 0x02);
				Eq_n cx_n;
				if (fn0800_BFC7(es_n->*bx_n.u4, out cx_n) == 0x02)
				{
					Mem462[ds:0x2A27:word16] = Mem433[ds:0x2A27:word16] + 0x01;
					if (Mem462[ds:0x2A27:word16] == Mem462[ds:9882:word16])
						si_n = fn0800-0DCE(cx_n, dx_n, bx_n, ds, out di);
					Eq_n es_bx_n = Mem462[ds:9884:segptr32];
					struct Eq_n * es_n = SLICE(es_bx_n, selector, 16);
					union Eq_n Eq_n::* bx_n = SLICE(es_bx_n, word16, 0) + (Mem462[ds:0x2A27:word16] << 0x02);
					ptrLoc06_n.u3 = (es_n->*bx_n).u3;
				}
				else
				{
					Eq_n es_bx_n = Mem433[ds:9884:segptr32];
					struct Eq_n * es_n = SLICE(es_bx_n, selector, 16);
					struct Eq_n Eq_n::* bx_n = SLICE(es_bx_n, word16, 0) + (Mem433[ds:0x2A27:word16] << 0x02);
					ptrLoc06_n = SEQ((es_n->*bx_n).w0002, (es_n->*bx_n).w0000 + 0x02);
				}
				if ((int16) *ptrLoc06_n.u3 == 0x00)
				{
					word16 cx_n;
					word16 dx_n;
					word16 bx_n;
					fn0800-0D24(ds, 0x02, SEQ(ds, 1500), out cx_n, out dx_n, out bx_n, out si_n, out di, out ds);
				}
			}
			byte Eq_n::* wLoc06_n = (word16) ptrLoc06_n;
			struct Eq_n * wLoc04_n = SLICE(ptrLoc06_n, word16, 16);
			if (si_n <= 0x0A)
			{
				switch (si_n)
				{
				case 0x00:
					if (Mem968[ds:10777:word16] == 0x00)
					{
						byte Eq_n::* di_n = wLoc06_n;
						word16 cx_n = ~0x00;
						while (cx_n != 0x00)
						{
							byte Eq_n::* di_n;
							di_n = di_n + 1;
							--cx_n;
							di_n = di_n;
							if (wLoc04_n->*di_n != 0x00)
								break;
						}
						cup16 cx_n = ~cx_n;
						byte ch_n = SLICE(cx_n - 0x01, byte, 8);
						if (cx_n > 0x02)
						{
							word16 cx_n;
							word16 dx_n;
							word16 bx_n;
							word16 si_n;
							word16 di_n;
							fn0800-0D24(ds, 0x03, ptrLoc06_n, out cx_n, out dx_n, out bx_n, out si_n, out di_n, out ds);
							ch_n = SLICE(cx_n, byte, 8);
						}
						Eq_n ax_n = fn0800-0C29(ds, SEQ(ds, 0x0844), *ptrLoc06_n.u3, out cl_n, out dx_n, out bx_n);
						Mem1057[ds:0x2A23:word16] = ax_n;
						Eq_n cx_n = SEQ(ch_n, cl_n);
						if (ax_n >= 0x06)
						{
							word16 bx_n;
							word16 si_n;
							word16 di_n;
							fn0800-0D24(ds, 0x03, ptrLoc06_n, out cx_n, out dx_n, out bx_n, out si_n, out di_n, out ds);
						}
						fn0800_BEA2(cx_n, dx_n, ds, SEQ(ds, 17009), SEQ(ds, 2123), out di);
					}
					break;
				case 0x01:
					di = fn0800_BF18(di, ds, 2127, ds);
					if (Mem925[ds:11855:word16] == 0x00)
					{
						word16 cx_n;
						word16 dx_n;
						word16 bx_n;
						word16 si_n;
						fn0800-0D24(ds, 0x04, ptrLoc06_n, out cx_n, out dx_n, out bx_n, out si_n, out di, out ds);
					}
					Mem967[ds:0x2A1F:word16] = 0x00;
					break;
				case 0x02:
					di = fn0800_BF18(di, ds, 0x0856, ds);
					if (Mem860[ds:0x2A21:word16] > 0x02 || Mem860[ds:0x2A21:word16] == 0x00 && Mem860[ds:0x2A25:word16] == 0x00)
					{
						word16 cx_n;
						word16 dx_n;
						word16 bx_n;
						word16 si_n;
						fn0800-0D24(ds, 0x05, ptrLoc06_n, out cx_n, out dx_n, out bx_n, out si_n, out di, out ds);
					}
					break;
				case 0x03:
					byte Eq_n::* di_n = wLoc06_n;
					word16 cx_n = ~0x00;
					while (cx_n != 0x00)
					{
						++di_n;
						--cx_n;
						if (wLoc04_n->*di_n != 0x00)
							break;
					}
					cu16 cx_n = ~cx_n;
					<unknown>* di_n = di_n - cx_n;
					uint32 size_n = (cx_n >> 0x01) *32 0x02;
					memcpy(*((word32) ds + 17022), di_n, size_n);
					memcpy((word16) size_n + 17022, &(wLoc04_n->*((char *) di_n + (word16) size_n)), cond(cx_n >> 0x01) & 0x02);
					fn0800-0C6C(ds, SEQ(ds, 17022));
					di.u0 = 17022;
					word16 cx_n = ~0x00;
					while (cx_n != 0x00)
					{
						di = (word16) di + 1;
						--cx_n;
						if (ds->*di != 0x00)
							break;
					}
					if ((ds->*~cx_n).b427C != 0x5C)
					{
						byte Eq_n::* di_n = 17022;
						word16 cx_n = ~0x00;
						while (cx_n != 0x00)
						{
							++di_n;
							--cx_n;
							if (ds->*di_n != 0x00)
								break;
						}
						<unknown>* di_n = di_n - 0x01;
						memcpy(di_n, *((word32) ds + 0x0859), 0x02);
						di = (char *) di_n + 2;
					}
					break;
				case 0x04:
					byte Eq_n::* di_n = wLoc06_n;
					word16 cx_n = ~0x00;
					while (cx_n != 0x00)
					{
						++di_n;
						--cx_n;
						if (wLoc04_n->*di_n != 0x00)
							break;
					}
					cu16 cx_n = ~cx_n;
					<unknown>* di_n = di_n - cx_n;
					uint32 size_n = (cx_n >> 0x01) *32 0x02;
					memcpy(*((word32) ds + 17123), di_n, size_n);
					memcpy((word16) size_n + 17123, &(wLoc04_n->*((char *) di_n + (word16) size_n)), cond(cx_n >> 0x01) & 0x02);
					fn0800-0C6C(ds, SEQ(ds, 17123));
					di.u0 = 17123;
					word16 cx_n = ~0x00;
					while (cx_n != 0x00)
					{
						di = (word16) di + 1;
						--cx_n;
						if (ds->*di != 0x00)
							break;
					}
					if ((ds->*~cx_n).b42E1 != 0x5C)
					{
						byte Eq_n::* di_n = 17123;
						word16 cx_n = ~0x00;
						while (cx_n != 0x00)
						{
							++di_n;
							--cx_n;
							if (ds->*di_n != 0x00)
								break;
						}
						<unknown>* di_n = di_n - 0x01;
						memcpy(di_n, *((word32) ds + 0x0859), 0x02);
						di = (char *) di_n + 2;
					}
					break;
				case 0x05:
					di = fn0800_BF18(di, ds, 2131, ds);
					break;
				case 0x06:
					Mem545[ds:0x2A1F:word16] = 0x01;
					Mem546[ds:11855:word16] = 0x00;
					break;
				case 0x07:
					Mem544[ds:10779:word16] = 0x01;
					break;
				case 0x08:
					Mem543[ds:10781:word16] = 0x01;
					break;
				case 0x09:
					Mem542[ds:10775:word16] = 0x01;
					break;
				case 0x0A:
					Mem541[ds:10773:word16] = 0x01;
					break;
				}
			}
			Mem1131[ds:0x2A27:word16] = Mem1127[ds:0x2A27:word16] + 0x01;
			ptrLoc06_n = ptrLoc06_n;
		}
		Eq_n ax_n = Mem48[ds:0x2A21:word16];
		if (ax_n != 0x01)
		{
			if (ax_n == 0x02)
			{
				byte Eq_n::* di_n = 17009;
				word16 cx_n = ~0x00;
				while (cx_n != 0x00)
				{
					++di_n;
					--cx_n;
					if (ds->*di_n != 0x00)
						break;
				}
				memcpy(di_n - 0x01, *((word32) ds + 2141), 0x02);
				if (Mem117[ds:11825:word16] >u 0x1000)
					Mem151[ds:11825:word16] = 0x1000;
				Mem153[ds:0x2E2F:word16] = 0xFF;
			}
		}
		else
		{
			byte Eq_n::* di_n = 17009;
			word16 cx_n = ~0x00;
			while (cx_n != 0x00)
			{
				++di_n;
				--cx_n;
				if (ds->*di_n != 0x00)
					break;
			}
			memcpy(di_n - 0x01, *((word32) ds + 0x085B), 0x02);
			if (Mem77[ds:11825:word16] >u 0x8000)
				Mem111[ds:11825:word16] = 0x8000;
			Mem113[ds:0x2E2F:word16] = 0x1000;
		}
		if (Mem155[ds:0x2A23:word16] == 0x02)
		{
			Mem162[ds:10781:word16] = 0x00;
			Mem163[ds:11855:word16] = 0x00;
		}
		if (Mem165[ds:11855:word16] != 0x00)
		{
			byte Eq_n::* di_n = 17009;
			word16 cx_n = ~0x00;
			while (cx_n != 0x00)
			{
				++di_n;
				--cx_n;
				if (ds->*di_n != 0x00)
					break;
			}
			memcpy(di_n - 0x01, *((word32) ds + 1619), 0x02);
		}
		if (Mem218[ds:10781:word16] != 0x00)
		{
			byte Eq_n::* di_n = 17009;
			word16 cx_n = ~0x00;
			while (cx_n != 0x00)
			{
				++di_n;
				--cx_n;
				if (ds->*di_n != 0x00)
					break;
			}
			memcpy(di_n - 0x01, *((word32) ds + 0x085F), 0x02);
		}
		byte Eq_n::* di_n = 17009;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (ds->*di_n != 0x00)
				break;
		}
		memcpy(di_n - 0x01, *((word32) ds + 0x0861), 0x05);
		if (Mem269[ds:0x2A25:word16] == 0x00 && Mem269[ds:0x0545[Mem269[ds:0x2A23:word16] * 0x04] + 0x00:byte] != 0x00)
			bp_n = fn0800-09A3(ds, out ds);
	}
	word16 bp_n = (ss->*bp_n).w0000;
	dsOut = ds;
	return bp_n;
}

// 0800:09A3: Register word16 fn0800-09A3(Register Eq_n ds, Register out (ptr16 Eq_n) dsOut)
// Called from:
//      fn0800-0541
//      fn0800-5E64
//      fn0800-669C
word16 fn0800-09A3(Eq_n ds, struct Eq_n & dsOut)
{
	Eq_n ds_n;
	word16 si_n;
	struct Eq_n Eq_n::* bp_n;
	Eq_n dx_n;
	uint32 ax_dx_n = SEQ((CONVERT(Mem15[ds:0x0A72:byte], int8, int16) << 0x08) + CONVERT(Mem15[ds:0x0A73:byte], uint8, uint16), 0x00) + CONVERT((CONVERT(Mem27[ds:2676:byte], int8, int16) << 0x08) + CONVERT(Mem27[ds:2677:byte], uint8, uint16), uint16, uint32);
	Eq_n ax_n = fn0800-4311(ds, SEQ(SLICE(ax_dx_n + 0x20, word16, 16), (word16) ax_dx_n + 0x20), out dx_n, out bp_n, out si_n, out ds_n);
	selector ss;
	(ss->*bp_n).tFFFFFFFE.u2 = (uint16) dx_n;
	(ss->*bp_n).tFFFFFFFC.u2 = (uint16) ax_n;
	(ss->*bp_n).tFFFFFFFA.u2 = (uint16) dx_n;
	(ss->*bp_n).tFFFFFFF8.u2 = (uint16) ax_n;
	Eq_n sp_n;
	sp_n.u0 = <invalid>;
	(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFFE.u2;
	(ss->*sp_n.u5).t0000.u1.u2 = (uint16) ax_n;
	ss->*((word32) sp_n - 2) = ds_n;
	(ss->*((word32) sp_n - 4)).u3 = 0x0A6E;
	fn0800-867A(ss->*((word32) sp_n - 4), ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0000.u1.u2, (ss->*sp_n.u5).t0002.u1.u6);
	while (true)
	{
		word16 si_n = (ss->*bp_n).w0004;
		(ss->*sp_n.u5).t0002.u1.u2 = (uint16) ds_n;
		Eq_n es_di_n;
		es_di_n.u3 = (ss->*bp_n).tFFFFFFF8.u3;
		struct Eq_n * ds_n = (ss->*bp_n).ptr0006;
		struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
		byte Eq_n::* di_n = (word16) es_di_n;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		word16 cx_n = ~cx_n;
		cui16 ax_n = 0x00;
		Eq_n cmpResult_n = memcmp(si_n, di_n - cx_n, (uint32) cx_n);
		if (cmpResult_n != 0x00)
		{
			cup16 ax_n = 0x00 - (word16) (cmpResult_n < 0x00);
			ax_n = ax_n - ~0x00 - (word16) (ax_n < 0x00);
		}
		ds_n.u6 = (ss->*sp_n.u5).t0002.u1.u6;
		if (ax_n == 0x00)
			break;
		Eq_n es_di_n;
		es_di_n.u3 = (ss->*bp_n).tFFFFFFF8.u3;
		struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
		byte Eq_n::* di_n = (word16) es_di_n;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			byte Eq_n::* di_n;
			di_n = di_n + 1;
			--cx_n;
			di_n = di_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		Eq_n di_n;
		di_n.u2 = (ss->*bp_n).tFFFFFFF8.u2;
		(ss->*sp_n.u5).t0002.u1.u2 = (uint16) ((int16) (es_n->*(((ss->*bp_n).tFFFFFFF8).u2 + -cx_n)).b0001 << 0x08);
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			Eq_n di_n;
			di_n.u3 = &di_n.u5->b0001;
			--cx_n;
			di_n = di_n;
			if (es_n->*di_n.u3 != 0x00)
				break;
		}
		word16 dx_n = (ss->*sp_n.u5).t0002.u1.u2 + (uint16) (es_n->*(((ss->*bp_n).tFFFFFFF8).u2 + -cx_n)).b0002;
		Eq_n di_n;
		di_n.u2 = (ss->*bp_n).tFFFFFFF8.u2;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			Eq_n di_n;
			di_n.u3 = &di_n.u5->b0001;
			--cx_n;
			di_n = di_n;
			if (es_n->*di_n.u3 != 0x00)
				break;
		}
		(ss->*bp_n).tFFFFFFF8.u2 = (uint16) ((ss->*bp_n).tFFFFFFF8.u2 + ((dx_n + -cx_n) + 0x03));
	}
	Eq_n es_di_n;
	es_di_n.u3 = (ss->*bp_n).tFFFFFFF8.u3;
	struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
	byte Eq_n::* di_n = (word16) es_di_n;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		byte Eq_n::* di_n;
		di_n = di_n + 1;
		--cx_n;
		di_n = di_n;
		if (es_n->*di_n != 0x00)
			break;
	}
	(ss->*bp_n).tFFFFFFF8.u2 = (uint16) ((ss->*bp_n).tFFFFFFF8.u2 + ~cx_n);
	Eq_n es_bx_n;
	es_bx_n.u3 = (ss->*bp_n).tFFFFFFF8.u3;
	(ss->*sp_n.u5).t0002.u1.u2 = (uint16) (((int16) *es_bx_n.u3 << 0x08) + (uint16) (es_bx_n.u5)->b0001 + 0x02);
	(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).tFFFFFFFA.u2;
	ss->*((word32) sp_n - 2) = (word16) es_bx_n;
	(ss->*((word32) sp_n - 4)).u3 = (ss->*bp_n).w000A;
	(ss->*((word32) sp_n - 6)).u2 = (ss->*bp_n).t0008.u2;
	fn0800_B0F3(ss->*((word32) sp_n - 6), ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0002.u1.u2);
	(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFFE.u2;
	(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).tFFFFFFFC.u2;
	word16 cx_n;
	word16 dx_n;
	word16 bx_n;
	struct Eq_n * ds_n;
	fn0800-4346(ds_n, (ss->*sp_n.u5).t0002.u1.u2, out cx_n, out dx_n, out bx_n, out ds_n);
	word16 bp_n = (ss->*bp_n).w0000;
	dsOut = ds_n;
	return bp_n;
}

// 0800:0ABC: Register Eq_n fn0800-0ABC(Register Eq_n ds, Stack Eq_n dwArg04, Register out Eq_n dxOut)
// Called from:
//      fn0800-0DE8
//      fn0800-112D
//      fn0800-12E2
//      fn0800-18D9
//      fn0800-19EE
Eq_n fn0800-0ABC(Eq_n ds, Eq_n dwArg04, union Eq_n & dxOut)
{
	word16 di_n;
	mp16 fp;
	Eq_n ss;
	word16 dx_n;
	fn0800-35A3(fp - 16, ss, dwArg04, out dx_n);
	Eq_n ax_n = fn0800-0B79(Mem44[ds:0x2A07:word32], Mem25[ds:0x2A03:word32]);
	uint32 dx_ax_n = (uint32) ax_n;
	Eq_n bx_n;
	bx_n.u0 = 100;
	Eq_n si_n = fn0800_B2EF(ax_n, dx_ax_n % 100, 100, ds, SEQ(ds, 0x0866), out di_n);
	if (Mem104[ds:0x2A25:word16] == 0x02 || si_n != 0x00)
	{
		word16 di_n;
		fn0800_B2EF(ax_n, dx_ax_n % 100, si_n << 0x02, ds, SEQ(ds, 0x0889), out di_n);
		bx_n = si_n << 0x02;
	}
	word16 di_n;
	fn0800_B2EF(ax_n, dx_ax_n % 100, bx_n, ds, SEQ(ds, 0x0827), out di_n);
	Mem180[ds:0x29F3:ui32] = Mem176[ds:0x29F3:ui32] + Mem160[ds:0x2A07:ui32];
	Eq_n dx_n = Mem180[ds:0x2A03:word16];
	Mem188[ds:0x29EF:ui32] = Mem184[ds:0x29EF:ui32] + SEQ(Mem180[ds:0x2A05:word16], dx_n);
	Mem191[ds:10771:word16] = Mem188[ds:10771:word16] + 0x01;
	dxOut = dx_n;
	return ax_n;
}

// 0800:0B79: Register word16 fn0800-0B79(Stack Eq_n dwArg02, Stack Eq_n dwArg06)
// Called from:
//      main
//      fn0800-0ABC
word16 fn0800-0B79(Eq_n dwArg02, Eq_n dwArg06)
{
	byte ch_n;
	word16 bx_n;
	word16 cx_n;
	mp16 fp;
	cup16 wArg02 = (word16) dwArg02;
	cup16 wArg04 = SLICE(dwArg02, word16, 16);
	cup16 wArg06 = (word16) dwArg06;
	cup16 wArg08 = SLICE(dwArg06, word16, 16);
	Eq_n sp_n = fp - 2;
	if (dwArg02 == 0x00 || dwArg06 == 0x00)
		return 0x00;
	Eq_n dwArg06_n = dwArg06;
	Eq_n dwArg02_n = dwArg02;
	if (wArg04 <= wArg08)
	{
		if (wArg04 != wArg08)
			return 0x00;
		dwArg02_n = dwArg02;
		if (wArg02 <= wArg06)
			return 0x00;
	}
	word16 wArg02_n;
	Eq_n wArg04_n;
	selector ss;
	while (true)
	{
		ui32 ax_dx_n = dwArg02_n - dwArg06_n;
		Eq_n wArg08_n;
		wArg08_n.u3 = SLICE(dwArg06_n, word16, 16);
		word16 wArg06_n = (word16) dwArg06_n;
		wArg02_n = (word16) dwArg02_n;
		wArg04_n.u3 = SLICE(dwArg02_n, word16, 16);
		cup16 dx_n = (word16) ax_dx_n;
		cup16 ax_n = SLICE(ax_dx_n, word16, 16);
		if (ax_n <= 0x06 && (ax_n != 0x06 || dx_n <= 0x8DB8))
			break;
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		(ss->*sp_n).w0000 = 0x00;
		(ss->*sp_n).wFFFFFFFE = 0x0A;
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) wArg04_n;
		(ss->*sp_n).wFFFFFFFA = wArg02_n;
		Eq_n dx_ax_n = fn0800-8BC2((ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3, out cx_n, out bx_n);
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		(ss->*((word32) sp_n - 2)).u3 = 0x00;
		(ss->*((word32) sp_n - 4)).u3 = 0x0A;
		ss->*((word32) sp_n - 6) = wArg08_n;
		(ss->*((word32) sp_n - 8)).u3 = wArg06_n;
		sp_n.u0 = <invalid>;
		word16 cx_n;
		word16 bx_n;
		dwArg06_n = fn0800-8BC2(ss->*((word32) sp_n - 0x0A), ss->*((word32) sp_n - 6), out cx_n, out bx_n);
		dwArg02_n = dx_ax_n;
	}
	struct Eq_n Eq_n::* sp_n = sp_n - 2;
	(ss->*sp_n).t0000.u2 = (uint16) wArg04_n;
	(ss->*sp_n).wFFFFFFFE = wArg02_n;
	ui32 cx_bx_n = dwArg02_n - dwArg06_n;
	ui32 dx_ax_n = fn0800-8F18(10000, SLICE(cx_bx_n, word16, 16), 0x00, (word16) cx_bx_n, out ch_n);
	(ss->*sp_n).tFFFFFFFC.u2 = SLICE(dx_ax_n, word16, 16);
	(ss->*sp_n).wFFFFFFFA = (word16) dx_ax_n;
	word16 cx_n;
	word16 bx_n;
	return (word16) fn0800-8BC2((ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3, out cx_n, out bx_n);
}

// 0800:0C08: Register word16 fn0800-0C08(Stack Eq_n wArg02)
// Called from:
//      fn0800-831D
//      fn0800-8407
word16 fn0800-0C08(Eq_n wArg02)
{
	Eq_n si_n = wArg02;
	word16 cx_n = 0x01;
	while (true)
	{
		uint32 dx_ax_n = (uint32) si_n;
		si_n = dx_ax_n /u 0x02;
		if (dx_ax_n /u 0x02 == 0x00)
			break;
		++cx_n;
	}
	return cx_n;
}

// 0800:0C29: Register word16 fn0800-0C29(Register Eq_n ds, Stack (ptr32 Eq_n) dwArg02, Stack Eq_n bArg06, Register out Eq_n clOut, Register out word16 dxOut, Register out word16 bxOut)
// Called from:
//      fn0800-0402
//      fn0800-0541
word16 fn0800-0C29(Eq_n ds, union Eq_n * dwArg02, Eq_n bArg06, union Eq_n & clOut, word16 & dxOut, word16 & bxOut)
{
	word16 dx_n;
	word16 wArg02 = (word16) dwArg02;
	Eq_n al_n = fn0800-97CC(ds, (int16) bArg06, out dx_n);
	union Eq_n * ptrLoc06_n = dwArg02;
	word16 wLoc06_n;
	word16 bx_n;
	while (true)
	{
		wLoc06_n = (word16) ptrLoc06_n;
		word16 wLoc04_n = SLICE(ptrLoc06_n, word16, 16);
		bx_n = (word16) ptrLoc06_n;
		if (ptrLoc06_n->u0 == 0x00 || ptrLoc06_n->u0 == al_n)
			break;
		ptrLoc06_n = SEQ(wLoc04_n, wLoc06_n + 0x01);
	}
	clOut = al_n;
	dxOut = 0x00;
	bxOut = bx_n;
	return wLoc06_n - wArg02;
}

// 0800:0C6C: Register word16 fn0800-0C6C(Register Eq_n ds, Stack Eq_n ptrArg02)
// Called from:
//      fn0800-0402
//      fn0800-0541
//      fn0800-2DE2
word16 fn0800-0C6C(Eq_n ds, Eq_n ptrArg02)
{
	word16 dx;
	while (true)
	{
		word16 wArg02_n = (word16) ptrArg02;
		word16 wArg04_n = SLICE(ptrArg02, word16, 16);
		if (*ptrArg02.u3 == 0x00)
			break;
		*ptrArg02.u3 = (char) fn0800-97CC(ds, (int16) *ptrArg02.u3, out dx);
		ptrArg02 = SEQ(wArg04_n, wArg02_n + 0x01);
	}
	return dx;
}

// 0800:0C93: void fn0800-0C93(Register Eq_n ds, Stack Eq_n dwArg02)
// Called from:
//      fn0800-0DE8
//      fn0800-112D
//      fn0800-12E2
//      fn0800-18D9
//      fn0800-19EE
void fn0800-0C93(Eq_n ds, Eq_n dwArg02)
{
	Eq_n bx_n;
	Eq_n ss;
	mp16 fp;
	Eq_n dx_n = fn0800-3509(fp - 0x0068, ss, dwArg02, out bx_n);
	byte Eq_n::* di_n = fp - 0x0068;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (ss->*di_n != 0x00)
			break;
	}
	ui16 cx_n = ~cx_n;
	<unknown>* di_n = di_n - cx_n;
	Eq_n cmpResult_n = memcmp(*((word32) ds + 10004), di_n, (uint32) cx_n);
	cui16 ax_n = 0x00;
	Eq_n cx_n = cx_n - __find_first_difference__(*((word32) ds + 10004), di_n);
	if (cmpResult_n != 0x00)
	{
		cup16 ax_n = 0x00 - (word16) (cmpResult_n < 0x00);
		ax_n = ax_n - ~0x00 - (word16) (ax_n < 0x00);
	}
	if (ax_n != 0x00)
	{
		word16 di_n;
		fn0800_B2EF(cx_n, dx_n, bx_n, ds, SEQ(ds, 0x088F), out di_n);
		byte Eq_n::* di_n = fp - 0x0068;
		dx_n = ds;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (ss->*di_n != 0x00)
				break;
		}
		uint16 cx_n = ~cx_n;
		<unknown>* di_n = di_n - cx_n;
		uint32 size_n = (cx_n >> 0x01) *32 0x02;
		memcpy(*((word32) ds + 10004), di_n, size_n);
		memcpy((word16) size_n + 10004, &(ss->*((char *) di_n + (word16) size_n)), cond(cx_n >> 0x01) & 0x02);
		cx_n.u0 = 0x00;
	}
	word16 di_n;
	fn0800_B2EF(cx_n, dx_n, bx_n, ds, SEQ(ds, 2206), out di_n);
}

// 0800:0D24: Register byte fn0800-0D24(Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n ptrArg04, Register out Eq_n cxOut, Register out word16 dxOut, Register out Eq_n bxOut, Register out Eq_n siOut, Register out (memptr Eq_n byte) diOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-0402
//      fn0800-0541
//      fn0800-12E2
//      fn0800-18D9
//      fn0800-19EE
//      fn0800-1CF6
//      fn0800-24FE
//      fn0800-3678
//      fn0800-37DF
//      fn0800-3C99
//      fn0800-3DCF
//      fn0800-3E9A
//      fn0800-4047
//      fn0800-4110
//      fn0800-4152
//      fn0800-4234
//      fn0800-4311
byte fn0800-0D24(Eq_n ds, Eq_n wArg02, Eq_n ptrArg04, union Eq_n & cxOut, word16 & dxOut, union Eq_n & bxOut, union Eq_n & siOut, byte & diOut, union Eq_n & dsOut)
{
	byte Eq_n::* di_n;
	Eq_n ds_n;
	Eq_n dx_n;
	word16 dx_n;
	Eq_n ds_n;
	fn0800-0DA9(ds, Mem14[ds:10715:word32], SEQ(ds, 0x4477), out dx_n, out ds_n);
	word16 dx_n;
	Eq_n ds_n;
	fn0800-0DA9(ds_n, Mem37[ds_n:10711:word32], SEQ(ds_n, 0x4412), out dx_n, out ds_n);
	Eq_n cx_n = fn0800-0DA9(ds_n, Mem60[ds_n:10707:word32], SEQ(ds_n, 0x43AD), out dx_n, out ds_n);
	word16 di_n;
	fn0800_B2EF(cx_n, dx_n, wArg02 << 0x02, ds_n, SEQ(ds_n, 2210), out di_n);
	Eq_n bx_n = (word16) ptrArg04;
	if (*ptrArg04.u3 != 0x00)
	{
		word16 di_n;
		fn0800_B2EF(cx_n, dx_n, bx_n, ds_n, SEQ(ds_n, 2214), out di_n);
	}
	Eq_n si_n = fn0800_B2EF(cx_n, dx_n, bx_n, ds_n, SEQ(ds_n, 0x0827), out di_n);
	word16 dx_n;
	fn0800-8B5A(ds_n, 0x01, out dx_n);
	cxOut = cx_n;
	dxOut = dx_n;
	bxOut = bx_n;
	siOut = si_n;
	diOut = di_n;
	dsOut = ds_n;
	return 0x00;
}

// 0800:0DA9: Register word16 fn0800-0DA9(Register Eq_n ds, Stack Eq_n dwArg02, Stack Eq_n dwArg06, Register out word16 dxOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-0D24
word16 fn0800-0DA9(Eq_n ds, Eq_n dwArg02, Eq_n dwArg06, word16 & dxOut, union Eq_n & dsOut)
{
	word16 cx;
	word16 dx;
	if (dwArg02 != 0x00)
	{
		cx = fn0800_A614(ds, dwArg02, out ds);
		dx = fn0800-8F7F(ds, dwArg06);
	}
	dxOut = dx;
	dsOut = ds;
	return cx;
}

// 0800:0DCE: Register Eq_n fn0800-0DCE(Register Eq_n cx, Register Eq_n dx, Register Eq_n bx, Register Eq_n ds, Register out (memptr Eq_n byte) diOut)
// Called from:
//      fn0800-0402
//      fn0800-0541
Eq_n fn0800-0DCE(Eq_n cx, Eq_n dx, Eq_n bx, Eq_n ds, byte & diOut)
{
	byte Eq_n::* di_n;
	Eq_n si_n = fn0800_B2EF(cx, dx, bx, ds, SEQ(ds, 2024), out di_n);
	word16 dx_n;
	fn0800-8B5A(ds, 0x00, out dx_n);
	diOut = di_n;
	return si_n;
}

// 0800:0DE8: Register Eq_n fn0800-0DE8(Register Eq_n cx, Register Eq_n dx, Register Eq_n ds)
// Called from:
//      main
Eq_n fn0800-0DE8(Eq_n cx, Eq_n dx, Eq_n ds)
{
	word16 di_n;
	mp16 fp;
	Eq_n ds_n;
	Eq_n si_n;
	Eq_n dx_n;
	Eq_n cx_n;
	Eq_n bx_n = Mem17[ds:0x2A25:word16];
	word16 di_n;
	fn0800_B2EF(cx, dx, bx_n << 0x02, ds, SEQ(ds, 2220), out di_n);
	if (Mem32[ds:11855:word16] != 0x00)
	{
		word16 di_n;
		fn0800_B2EF(cx, dx, bx_n << 0x02, ds, SEQ(ds, 2234), out di_n);
	}
	if (Mem65[ds:0x2A1F:word16] != 0x00)
	{
		word16 di_n;
		fn0800_B2EF(cx, dx, bx_n << 0x02, ds, SEQ(ds, 2255), out di_n);
	}
	word16 di_n;
	fn0800_B2EF(cx, dx, bx_n << 0x02, ds, SEQ(ds, 2268), out di_n);
	Eq_n dx_n;
	word16 si_n;
	Eq_n ds_n;
	fn0800-37BE(fn0800-3678(ds, SEQ(ds, 17022), out dx_n, out si_n, out ds_n), dx_n, ds_n, SEQ(ds_n, 0x4477));
	Eq_n ax_n = fn0800-4234(ds_n, SEQ(ds_n, 0x4477), SEQ(ds_n, 2284), out cx_n, out dx_n, out si_n, out ds_n);
	Mem173[ds_n:10717:word16] = dx_n;
	Mem174[ds_n:10715:word16] = ax_n;
	word16 cx_n;
	word16 dx_n;
	word16 si_n;
	Eq_n ds_n;
	while (fn0800-2DE2(cx_n, dx_n, si_n, ds_n, SEQ(ds_n, 0x4541), out cx_n, out dx_n, out si_n, out ds_n) != 0x00)
	{
		fn0800-3764(ds_n);
		if (fn0800-388C(ds_n, out cx_n, out dx_n, out si_n, out ds_n) != 0x00)
		{
			fn0800-0C93(ds_n, SEQ(ds_n, 0x4541));
			Eq_n dx_ax_n = fn0800-4194(ds_n, Mem272[ds_n:0x29E3:word32]);
			Eq_n dx_n;
			dx_n.u3 = SLICE(dx_ax_n, word16, 16);
			Mem302[ds_n:0x2A09:word16] = dx_n;
			Eq_n ax_n = (word16) dx_ax_n;
			Mem303[ds_n:0x2A07:word16] = ax_n;
			Mem304[ds_n:0x2A05:word16] = dx_n;
			Mem305[ds_n:0x2A03:word16] = ax_n;
			Eq_n sp_n = fp - 0x02;
			si_n.u0 = 0x00;
			selector ss;
			if (Mem305[ds_n:0x2A09:word16] <=u 0x00 && (Mem305[ds_n:0x2A09:word16] != 0x00 || Mem305[ds_n:0x2A07:word16] <=u 0x12) && Mem305[ds_n:10773:word16] == 0x00)
				si_n.u0 = 0x03;
			else if (fn0800-3992(ds_n, out ds_n) != 0x00)
				si_n.u0 = 0x0E;
			else
			{
				Eq_n bx_n = Mem305[ds_n:0x2A23:word16];
				if (bx_n <= 0x05)
				{
					switch (bx_n)
					{
					case 0x00:
						si_n = fn0800-6AD4(ds_n, out ds_n);
						break;
					case 0x01:
						if (Mem305[ds_n:0x2A09:word16] >=u 0x00 && (Mem305[ds_n:0x2A09:word16] != 0x00 || Mem305[ds_n:0x2A07:word16] >=u 0x12))
						{
							int32 dx_ax_n = fn0800-8CAA(fn0800-3F58(ds_n, Mem305[ds_n:0x29E3:word32], out di_n, out ds_n), 0x08);
							word16 ax_n = (word16) dx_ax_n;
							if (SLICE(dx_ax_n, word16, 16) == 0x52 && ax_n == 0x4E43)
								si_n.u0 = 0x04;
						}
						sp_n = fp - 2;
						if (si_n == 0x00)
						{
							fn0800-75EA(ds_n, Mem500[ds_n:0x2A07:word16], Mem497[ds_n:0x2A09:word16], Mem489[ds_n:0x2A07:word32], out si_n, out ds_n);
							Eq_n sp_n;
							sp_n.u0 = <invalid>;
							sp_n.u3 = &sp_n.u5->t0008.u0;
							Eq_n ax_n = Mem503[ds_n:0x2A05:word16];
							Eq_n dx_n = Mem503[ds_n:0x2A03:word16];
							if (ax_n >=u Mem503[ds_n:0x2A09:word16] && (ax_n != Mem503[ds_n:0x2A09:word16] || dx_n >=u Mem503[ds_n:0x2A07:word16]) && Mem503[ds_n:10773:word16] != 0x00)
							{
								Mem534[ss:sp_n + 0x06:word16] = Mem503[ds_n:0x29E5:word16];
								Mem537[ss:sp_n + 0x04:word16] = Mem534[ds_n:0x29E3:word16];
								fn0800_BA67(ds_n, (ss->*sp_n.u5).t0004.u1.u3);
								Mem552[ss:sp_n + 0x06:word16] = Mem537[ds_n:10721:word16];
								Mem555[ss:sp_n + 0x04:word16] = Mem552[ds_n:10719:word16];
								fn0800_BA67(ds_n, (ss->*sp_n.u5).t0004.u1.u3);
								Mem570[ss:sp_n + 0x06:word16] = Mem555[ds_n:10721:word16];
								Mem573[ss:sp_n + 0x04:word16] = Mem570[ds_n:10719:word16];
								(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 21070;
								(ss->*sp_n.u5).t0000.u1.u2 = (uint16) 0x4300;
								Eq_n ds_n = fn0800-409C(ds_n, (ss->*sp_n.u5).t0000.u1.u2, (ss->*sp_n.u5).t0002.u1.u2, (ss->*sp_n.u5).t0004.u1.u3);
								Mem595[ss:sp_n + 0x06:word16] = Mem579[ds_n:10721:word16];
								Mem598[ss:sp_n + 0x04:word16] = Mem595[ds_n:10719:word16];
								Mem601[ss:sp_n + 0x02:word16] = Mem598[ds_n:0x2A09:word16];
								Mem604[ss:sp_n + 0x00:word16] = Mem601[ds_n:0x2A07:word16];
								Eq_n ds_n = fn0800-409C(ds_n, (ss->*sp_n.u5).t0000.u1.u2, (ss->*sp_n.u5).t0002.u1.u2, (ss->*sp_n.u5).t0004.u1.u3);
								Mem620[ss:sp_n + 0x06:word16] = Mem604[ds_n:0x2A09:word16];
								Mem623[ss:sp_n + 0x04:word16] = Mem620[ds_n:0x2A07:word16];
								Mem626[ss:sp_n + 0x02:word16] = Mem623[ds_n:10721:word16];
								Mem629[ss:sp_n + 0x00:word16] = Mem626[ds_n:10719:word16];
								Mem632[ss:sp_n + -2:word16] = Mem629[ds_n:0x29E5:word16];
								Mem635[ss:sp_n + -4:word16] = Mem632[ds_n:0x29E3:word16];
								word16 si_n;
								fn0800-3B0A(ds_n, (ss->*sp_n.u5).t0004.u1.u2, (ss->*sp_n.u5).t0006.u2, out si_n, out ds_n);
								Eq_n sp_n;
								sp_n.u0 = <invalid>;
								sp_n.u3 = &sp_n.u5->t000C.u0;
								si_n.u0 = 0x02;
							}
						}
						break;
					case 0x02:
						si_n = fn0800-741D(ds_n);
						break;
					case 0x03:
						si_n = fn0800-73AC(ds_n, out ds_n);
						break;
					case 0x04:
						Eq_n ds_n;
						if (fn0800-3F0A(ds_n, Mem305[ds_n:0x29E3:word32], out ds_n) == 0x4D5A)
						{
							sp_n.u0 = <invalid>;
							si_n = fn0800-5E64(ds_n, out ds_n);
						}
						else
						{
							sp_n.u0 = <invalid>;
							si_n = fn0800-669C(ds_n, out ds_n);
						}
						break;
					case 0x05:
						sp_n.u0 = <invalid>;
						si_n = fn0800-67BF(ds_n, out ds_n);
						break;
					}
				}
				struct Eq_n Eq_n::* sp_n = sp_n - 2;
				Mem673[ss:sp_n + 0x00:word16] = Mem668[ds_n:10721:word16];
				Mem676[ss:sp_n + -2:word16] = Mem673[ds_n:10719:word16];
				Eq_n dx_ax_n = fn0800-4194(ds_n, (ss->*sp_n).tFFFFFFFE.u3);
				Mem688[ds_n:0x2A05:word16] = SLICE(dx_ax_n, word16, 16);
				Mem689[ds_n:0x2A03:word16] = SLICE(dx_ax_n, word16, 0);
				sp_n.u3 = (char *) &sp_n->t0000 + 2;
				Eq_n ax_n = Mem689[ds_n:0x2A05:word16];
				Eq_n dx_n = Mem689[ds_n:0x2A03:word16];
				if (ax_n >=u Mem689[ds_n:0x2A09:word16] && (ax_n != Mem689[ds_n:0x2A09:word16] || dx_n >=u Mem689[ds_n:0x2A07:word16]) && Mem689[ds_n:10773:word16] == 0x00)
				{
					Eq_n dx_n = Mem689[ds_n:0x2A07:word16];
					Mem703[ds_n:0x2A05:word16] = Mem689[ds_n:0x2A09:word16];
					Mem704[ds_n:0x2A03:word16] = dx_n;
					si_n.u0 = 0x03;
				}
				if (si_n == 0x04)
				{
					Eq_n dx_n = Mem713[ds_n:0x2A07:word16];
					Mem716[ds_n:0x2A05:word16] = Mem713[ds_n:0x2A09:word16];
					Mem717[ds_n:0x2A03:word16] = dx_n;
				}
			}
			if (Mem721[ds_n:17022:byte] != 0x00 && (si_n == 0x03 || si_n == 0x04))
			{
				Eq_n dx_n = Mem721[ds_n:0x2A07:word16];
				Mem733[ds_n:0x2A05:word16] = Mem721[ds_n:0x2A09:word16];
				Mem734[ds_n:0x2A03:word16] = dx_n;
				struct Eq_n Eq_n::* sp_n = sp_n - 2;
				Mem745[ss:sp_n + 0x00:word16] = Mem734[ds_n:0x29E5:word16];
				Mem748[ss:sp_n + -2:word16] = Mem745[ds_n:0x29E3:word16];
				fn0800_BA67(ds_n, (ss->*sp_n).tFFFFFFFE.u3);
				Mem763[ss:sp_n + 0x00:word16] = Mem748[ds_n:10721:word16];
				Mem766[ss:sp_n + -2:word16] = Mem763[ds_n:10719:word16];
				fn0800_BA67(ds_n, (ss->*sp_n).tFFFFFFFE.u3);
				Mem781[ss:sp_n + 0x00:word16] = Mem766[ds_n:0x2A09:word16];
				Mem784[ss:sp_n + -2:word16] = Mem781[ds_n:0x2A07:word16];
				Mem787[ss:sp_n + -4:word16] = Mem784[ds_n:10721:word16];
				Mem790[ss:sp_n + -6:word16] = Mem787[ds_n:10719:word16];
				Mem793[ss:sp_n + -8:word16] = Mem790[ds_n:0x29E5:word16];
				Mem796[ss:sp_n + -0x0A:word16] = Mem793[ds_n:0x29E3:word16];
				word16 si_n;
				fn0800-3B0A(ds_n, (ss->*sp_n).tFFFFFFFE.u2, (ss->*sp_n).t0000.u2, out si_n, out ds_n);
				Eq_n sp_n;
				sp_n.u0 = <invalid>;
				sp_n.u3 = &sp_n.u5->t000C.u0;
				si_n.u0 = 0x00;
			}
			struct Eq_n Eq_n::* sp_n = sp_n - 2;
			Mem822[ss:sp_n + 0x00:word16] = Mem817[ds_n:0x29E5:word16];
			Mem825[ss:sp_n + -2:word16] = Mem822[ds_n:0x29E3:word16];
			Eq_n ds_n;
			fn0800_A614(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out ds_n);
			Mem841[ss:sp_n + 0x00:word16] = Mem825[ds_n:10721:word16];
			Mem844[ss:sp_n + -2:word16] = Mem841[ds_n:10719:word16];
			fn0800_A614(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out ds_n);
			if (si_n > 0x02)
			{
				(ss->*sp_n).t0000.u2 = (uint16) ds_n;
				(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x44DC;
				fn0800-8F7F(ds_n, (ss->*sp_n).tFFFFFFFE.u3);
			}
			else
				si_n = fn0800-37DF(ds_n, out ds_n);
			struct Eq_n Eq_n::* sp_n = sp_n - 2;
			(ss->*sp_n).t0000.u2 = (uint16) ds_n;
			(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x4541;
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) si_n;
			cx_n = fn0800-0ABC(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out dx_n);
		}
	}
	Eq_n ds_n;
	fn0800_A614(ds_n, Mem182[ds_n:10715:word32], out ds_n);
	fn0800-8F7F(ds_n, SEQ(ds_n, 0x4477));
	return ds_n;
}

// 0800:112D: Register Eq_n fn0800-112D(Register Eq_n cx, Register Eq_n dx, Register Eq_n ds)
// Called from:
//      main
Eq_n fn0800-112D(Eq_n cx, Eq_n dx, Eq_n ds)
{
	word16 di_n;
	mp16 fp;
	word16 di_n;
	Eq_n bx_n = Mem17[ds:0x2A25:word16];
	word16 di_n;
	fn0800_B2EF(cx, dx, bx_n << 0x02, ds, SEQ(ds, 2288), out di_n);
	if (Mem32[ds:11855:word16] != 0x00)
	{
		word16 di_n;
		fn0800_B2EF(cx, dx, bx_n << 0x02, ds, SEQ(ds, 2302), out di_n);
	}
	Eq_n si_n = fn0800_B2EF(cx, dx, bx_n << 0x02, ds, SEQ(ds, 2323), out di_n);
	if (Mem71[ds:0x2A25:word16] == 0x01)
		cx = fn0800-3678(ds, SEQ(ds, 17022), out dx, out si_n, out ds);
	word16 cx_n;
	word16 dx_n;
	word16 si_n;
	Eq_n ds_n;
	while (fn0800-2DE2(cx, dx, si_n, ds, SEQ(ds, 0x4541), out cx_n, out dx_n, out si_n, out ds_n) != 0x00)
	{
		fn0800-3764(ds_n);
		if (fn0800-388C(ds_n, out cx, out dx, out si_n, out ds) != 0x00)
		{
			fn0800-0C93(ds, SEQ(ds, 0x4541));
			Eq_n dx_ax_n = fn0800-4194(ds, Mem169[ds:0x29E3:word32]);
			Eq_n dx_n;
			dx_n.u3 = SLICE(dx_ax_n, word16, 16);
			Mem199[ds:0x2A05:word16] = dx_n;
			Eq_n ax_n = (word16) dx_ax_n;
			Mem200[ds:0x2A03:word16] = ax_n;
			Eq_n sp_n = fp - 0x02;
			if (dx_n <= 0x00 && (false || ax_n < 0x12))
				si_n.u0 = 0x07;
			else
			{
				Eq_n bx_n = Mem200[ds:0x2A23:word16];
				if (bx_n <= 0x05)
				{
					switch (bx_n)
					{
					case 0x00:
						si_n = fn0800-4C55(ds, out ds);
						break;
					case 0x01:
						int32 dx_ax_n = fn0800-8CAA(fn0800-3F58(ds, Mem200[ds:0x29E3:word32], out di_n, out ds), 0x08);
						sp_n = fp - 0x02;
						word16 ax_n = (word16) dx_ax_n;
						if (SLICE(dx_ax_n, word16, 16) == 0x52 && ax_n == 0x4E43)
						{
							sp_n.u0 = <invalid>;
							word16 bp_n;
							si_n = fn0800-5374(ds, out bp_n, out ds);
						}
						else
							si_n.u0 = 0x07;
						break;
					case 0x02:
						sp_n.u0 = <invalid>;
						si_n = fn0800-51A9(ds, out ds);
						break;
					case 0x03:
						si_n = fn0800-518F(ds, out ds);
						break;
					case 0x04:
						sp_n = fp - 0x02;
						Eq_n ds_n;
						if (fn0800-3F0A(ds, Mem200[ds:0x29E3:word32], out ds_n) == 0x4D5A)
						{
							sp_n.u0 = <invalid>;
							si_n = fn0800-46FE(ds_n, out ds);
						}
						else
							si_n = fn0800-4B97(ds_n, out ds);
						break;
					case 0x05:
						si_n = fn0800-4BB1(ds, out ds);
						break;
					}
				}
			}
			struct Eq_n Eq_n::* sp_n = sp_n - 2;
			selector ss;
			Mem395[ss:sp_n + 0x00:word16] = Mem384[ds:10721:word16];
			Mem398[ss:sp_n + -2:word16] = Mem395[ds:10719:word16];
			Eq_n dx_ax_n = fn0800-4194(ds, (ss->*sp_n).tFFFFFFFE.u3);
			Mem411[ds:0x2A09:word16] = SLICE(dx_ax_n, word16, 16);
			Mem412[ds:0x2A07:word16] = SLICE(dx_ax_n, word16, 0);
			Mem415[ss:sp_n + 0x00:word16] = Mem412[ds:0x29E5:word16];
			Mem418[ss:sp_n + -2:word16] = Mem415[ds:0x29E3:word16];
			Eq_n dx_ax_n = fn0800-4194(ds, (ss->*sp_n).tFFFFFFFE.u3);
			Mem430[ds:0x2A05:word16] = SLICE(dx_ax_n, word16, 16);
			Mem431[ds:0x2A03:word16] = SLICE(dx_ax_n, word16, 0);
			if (si_n != 0x00)
			{
				Eq_n dx_n = Mem431[ds:0x2A03:word16];
				Mem441[ds:0x2A09:word16] = Mem431[ds:0x2A05:word16];
				Mem442[ds:0x2A07:word16] = dx_n;
			}
			Mem449[ss:sp_n + 0x00:word16] = Mem444[ds:0x29E5:word16];
			Mem452[ss:sp_n + -2:word16] = Mem449[ds:0x29E3:word16];
			Eq_n ds_n;
			fn0800_A614(ds, (ss->*sp_n).tFFFFFFFE.u3, out ds_n);
			Mem468[ss:sp_n + 0x00:word16] = Mem452[ds_n:10721:word16];
			Mem471[ss:sp_n + -2:word16] = Mem468[ds_n:10719:word16];
			fn0800_A614(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out ds);
			if (Mem471[ds:0x2A25:word16] != 0x02 && si_n == 0x00)
				si_n = fn0800-37DF(ds, out ds);
			else
			{
				(ss->*sp_n).t0000.u2 = (uint16) ds;
				(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x44DC;
				fn0800-8F7F(ds, (ss->*sp_n).tFFFFFFFE.u3);
			}
			struct Eq_n Eq_n::* sp_n = sp_n - 2;
			(ss->*sp_n).t0000.u2 = (uint16) ds;
			(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x4541;
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) si_n;
			cx = fn0800-0ABC(ds, (ss->*sp_n).tFFFFFFFE.u3, out dx);
		}
	}
	return ds_n;
}

// 0800:12E2: Register word16 fn0800-12E2(Register Eq_n cx, Register Eq_n dx, Register Eq_n ds, Register out (ptr16 Eq_n) dsOut)
// Called from:
//      main
word16 fn0800-12E2(Eq_n cx, Eq_n dx, Eq_n ds, struct Eq_n & dsOut)
{
	Eq_n ds_n;
	word16 dx_n;
	word16 di_n;
	word16 dx_n;
	byte cl_n;
	word16 dx_n;
	byte cl_n;
	Eq_n dx_n;
	Eq_n dx_n;
	Eq_n ds_n;
	word16 si_n;
	Eq_n dx_n;
	word16 cx_n;
	Eq_n ds_n;
	Eq_n si_n;
	Eq_n dx_n;
	Eq_n cx_n;
	Eq_n ds_n;
	word16 si_n;
	struct Eq_n Eq_n::* bp_n;
	word16 dx_n;
	Eq_n dx_n;
	Eq_n dx_n;
	Eq_n dx_n;
	Eq_n ds_n;
	word16 si_n;
	struct Eq_n Eq_n::* bp_n;
	Eq_n dx_n;
	word16 si_n;
	Eq_n dx_n;
	word16 cx_n;
	Eq_n ds_n;
	word16 cx_n;
	Eq_n bx_n = Mem21[ds:0x2A25:word16];
	word16 di_n;
	fn0800_B2EF(cx, dx, bx_n << 0x02, ds, SEQ(ds, 2326), out di_n);
	if (Mem36[ds:11855:word16] != 0x00)
	{
		word16 di_n;
		fn0800_B2EF(cx, dx, bx_n << 0x02, ds, SEQ(ds, 0x0925), out di_n);
	}
	word16 di_n;
	fn0800_B2EF(cx, dx, bx_n << 0x02, ds, SEQ(ds, 2362), out di_n);
	Eq_n dx_ax_n = fn0800_AA7E(ds, SEQ(ds, 0x4348), SEQ(ds, 0x093D), out cx_n, out ds_n);
	Mem110[ds_n:10705:word16] = SLICE(dx_ax_n, word16, 16);
	Mem111[ds_n:10703:word16] = SLICE(dx_ax_n, word16, 0);
	Eq_n ax_n = Mem111[ds_n:0x2A25:word16];
	Eq_n ss;
	switch (ax_n)
	{
	case 0x03:
		if ((Mem111[ds_n:10703:word16] | Mem111[ds_n:10705:word16]) == 0x00)
		{
			word16 cx_n;
			word16 dx_n;
			word16 bx_n;
			word16 si_n;
			word16 di_n;
			fn0800-0D24(ds_n, 0x07, SEQ(ds_n, 0x4348), out cx_n, out dx_n, out bx_n, out si_n, out di_n, out ds_n);
		}
		break;
	case 0x04:
		if ((Mem111[ds_n:10703:word16] | Mem111[ds_n:10705:word16]) != 0x00)
		{
			word16 cx_n;
			word16 di_n;
			if (fn0800-3E27(ds_n, Mem111[ds_n:10703:word32], out cx_n, out di_n, out ds_n) == 0x4D5A)
			{
				word16 cx_n;
				fn0800_ACB3(ds_n, Mem184[ds_n:10703:word32], 0x00, 0x02, out cx_n);
				Eq_n dx_ax_n = fn0800_AD2F(ds_n, Mem190[ds_n:10703:word32]);
				Mem220[ds_n:10733:word16] = SLICE(dx_ax_n, word16, 16);
				Mem221[ds_n:10731:word16] = SLICE(dx_ax_n, word16, 0);
			}
			else
			{
				Mem172[ds_n:10705:word16] = 0x00;
				Mem173[ds_n:10703:word16] = 0x00;
			}
		}
		if ((Mem223[ds_n:10703:word16] | Mem223[ds_n:10705:word16]) == 0x00)
		{
			Eq_n ax_n = fn0800-4234(ds_n, SEQ(ds_n, 0x4348), SEQ(ds_n, 0x0941), out cx_n, out dx_n, out si_n, out ds_n);
			Mem256[ds_n:10705:word16] = dx_n;
			Mem257[ds_n:10703:word16] = ax_n;
			Mem258[ds_n:10733:word16] = 0x00;
			Mem259[ds_n:10731:word16] = 0x00;
		}
		mp16 fp;
		byte cl_n;
		word16 dx_n;
		fn0800-2CCF(ds_n, SEQ(ss, fp - 0x0068), 0x04, 0x00, out cl_n, out dx_n);
		byte cl_n;
		word16 dx_n;
		fn0800-2CCF(ds_n, SEQ(ss, fp - 0x0068), 0x04, 0x00, out cl_n, out dx_n);
		word16 si_n;
		Eq_n ds_n;
		fn0800-4152(ds_n, SEQ(ss, fp - 112), 0x0C, 0x00, Mem329[ds_n:10703:word32], out si_n, out ds_n);
		ds_n = fn0800-409C(ds_n, Mem372[ds_n:10731:word16], Mem369[ds_n:10733:word16], Mem349[ds_n:10703:word32]);
		break;
	}
	Eq_n sp_n;
	sp_n.u0 = <invalid>;
	Eq_n cx_n = fn0800-1CF6(ds_n, 0x00, out dx_n, out bp_n, out si_n, out ds_n);
	struct Eq_n Eq_n::* sp_n = (struct Eq_n Eq_n::*) &sp_n.u5->t0002.u0;
	Eq_n si_n;
	si_n.u0 = 0x00;
	Eq_n es_bx_n;
	do
	{
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		(ss->*sp_n).t0000.u2 = (uint16) ds_n;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x4541;
		sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0000 + 2);
		word16 cx_n;
		word16 dx_n;
		if (fn0800-2DE2(cx_n, dx_n, si_n, ds_n, (ss->*sp_n).tFFFFFFFE.u3, out cx_n, out dx_n, out si_n, out ds_n) == 0x00)
			break;
		(ss->*sp_n).t0000.u2 = (uint16) ds_n;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x4541;
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) ss;
		(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (bp_n - 110);
		word16 bx_n;
		fn0800-3509((ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u6, (ss->*sp_n).tFFFFFFFE.u3, out bx_n);
		(ss->*sp_n).t0000.u2 = (uint16) ds_n;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x4541;
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) ss;
		(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (bp_n - 0x84);
		word16 dx_n;
		fn0800-35A3((ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u6, (ss->*sp_n).tFFFFFFFE.u3, out dx_n);
		(ss->*sp_n).t0000.u2 = (uint16) ss;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) (bp_n - 110);
		Eq_n ax_n = fn0800-283D(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out dx_n);
		(ss->*bp_n).tFFFFFFFE.u2 = (uint16) dx_n;
		(ss->*bp_n).tFFFFFFFC.u2 = (uint16) ax_n;
		if ((ax_n | dx_n) == 0x00)
		{
			(ss->*sp_n).t0000.u2 = (uint16) ss;
			(ss->*sp_n).tFFFFFFFE.u2 = (uint16) (bp_n - 110);
			Eq_n ax_n = fn0800-1F5C(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out dx_n);
			(ss->*bp_n).tFFFFFFFE.u2 = (uint16) dx_n;
			(ss->*bp_n).tFFFFFFFC.u2 = (uint16) ax_n;
		}
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		(ss->*sp_n).t0000.u2 = (ss->*bp_n).tFFFFFFFE.u2;
		(ss->*sp_n).tFFFFFFFE.u2 = (ss->*bp_n).tFFFFFFFC.u2;
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) ss;
		(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (bp_n - 0x84);
		Eq_n ax_n = fn0800-2931((ss->*sp_n).tFFFFFFFA.u3, (ss->*sp_n).tFFFFFFFE.u3, out dx_n);
		(ss->*bp_n).tFFFFFFFA.u2 = (uint16) dx_n;
		(ss->*bp_n).tFFFFFFF8.u2 = (uint16) ax_n;
		if ((ax_n | dx_n) == 0x00)
		{
			(ss->*sp_n).t0000.u2 = (ss->*bp_n).tFFFFFFFE.u2;
			(ss->*sp_n).tFFFFFFFE.u2 = (ss->*bp_n).tFFFFFFFC.u2;
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) ss;
			(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (bp_n - 0x84);
			fn0800-2085(ds_n, (ss->*sp_n).tFFFFFFFA.u3, (ss->*sp_n).tFFFFFFFE.u3);
			sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0000 + 2);
		}
		else
		{
			(ss->*sp_n).t0000.u2 = (ss->*bp_n).tFFFFFFFA.u2;
			(ss->*sp_n).tFFFFFFFE.u2 = (ss->*bp_n).tFFFFFFF8.u2;
			word16 si_n;
			fn0800-23EC(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out bp_n, out si_n, out ds_n);
			Eq_n sp_n;
			sp_n.u0 = <invalid>;
			sp_n = (struct Eq_n Eq_n::*) &sp_n.u5->t0004.u0;
		}
		es_bx_n = Mem617[ds_n:11857:segptr32];
		dx_n.u2 = (uint16) *((word32) es_bx_n + 5);
		si_n.u0 = 0x01;
		cx_n.u0 = 0x08;
	} while ((word16) dx_n.u2 + ((uint16) ((es_bx_n.u5)->t0004).u0 << 0x08) < ~0x73);
	if (si_n != 0x00)
	{
		Eq_n ds_n;
		fn0800-1E5E(ds_n, out ds_n);
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		(ss->*sp_n).t0000.u2 = (uint16) 0x01;
		Eq_n cx_n = fn0800-1CF6(ds_n, (ss->*sp_n).t0000.u2, out dx_n, out bp_n, out si_n, out ds_n);
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		(ss->*sp_n.u5).t0000.u1.u2 = (uint16) 0x01;
		(ss->*((word32) sp_n - 2)).u0 = 0x00;
		fn0800-2DBF(ds_n, ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0000.u1.u2);
		Eq_n dx_n = Mem683[ds_n:10703:word16];
		Mem689[ds_n:10721:word16] = Mem683[ds_n:10705:word16];
		Mem690[ds_n:10719:word16] = dx_n;
		(ss->*sp_n.u5).t0000.u1.u2 = (uint16) ds_n;
		(ss->*((word32) sp_n - 2)).u0 = 2373;
		ss->*((word32) sp_n - 4) = ds_n;
		(ss->*((word32) sp_n - 6)).u0 = 0x4477;
		fn0800-37BE(cx_n, dx_n, ds_n, ss->*((word32) sp_n - 6));
		(ss->*sp_n.u5).t0000.u1.u2 = (uint16) ds_n;
		(ss->*((word32) sp_n - 2)).u0 = 0x0941;
		ss->*((word32) sp_n - 4) = ds_n;
		(ss->*((word32) sp_n - 6)).u0 = 0x4477;
		Eq_n ax_n = fn0800-4234(ds_n, ss->*((word32) sp_n - 6), ss->*((word32) sp_n - 2), out cx_n, out dx_n, out si_n, out ds_n);
		Mem737[ds_n:10717:word16] = dx_n;
		Mem738[ds_n:10715:word16] = ax_n;
		struct Eq_n Eq_n::* sp_n = (struct Eq_n Eq_n::*) &sp_n.u5->t0002.u0;
		struct Eq_n Eq_n::* sp_n;
		struct Eq_n Eq_n::* sp_n;
		Eq_n es_bx_n;
		Eq_n bx_n;
		do
		{
			struct Eq_n Eq_n::* sp_n = sp_n - 2;
			(ss->*sp_n).t0000.u2 = (uint16) ds_n;
			(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x4541;
			sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0000 + 2);
			word16 cx_n;
			word16 dx_n;
			word16 si_n;
			if (fn0800-2DE2(cx_n, dx_n, si_n, ds_n, (ss->*sp_n).tFFFFFFFE.u3, out cx_n, out dx_n, out si_n, out ds_n) == 0x00)
				goto l0800_nA9;
			(ss->*sp_n).t0000.u2 = (uint16) ds_n;
			(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x093D;
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) ds_n;
			(ss->*sp_n).tFFFFFFFA.u2 = (uint16) 0x4541;
			Eq_n ax_n = fn0800-4234(ds_n, (ss->*sp_n).tFFFFFFFA.u3, (ss->*sp_n).tFFFFFFFE.u3, out cx_n, out dx_n, out si_n, out ds_n);
			Mem794[ds_n:0x29E5:word16] = dx_n;
			Mem795[ds_n:0x29E3:word16] = ax_n;
			(ss->*sp_n).t0000.u2 = (uint16) ds_n;
			(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x4541;
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) ss;
			(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (bp_n - 110);
			word16 bx_n;
			fn0800-3509((ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u6, (ss->*sp_n).tFFFFFFFE.u3, out bx_n);
			(ss->*sp_n).t0000.u2 = (uint16) ds_n;
			(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x4541;
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) ss;
			(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (bp_n - 0x84);
			word16 dx_n;
			fn0800-35A3((ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u6, (ss->*sp_n).tFFFFFFFE.u3, out dx_n);
			(ss->*sp_n).t0000.u2 = (uint16) ds_n;
			(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x4541;
			fn0800-0C93(ds_n, (ss->*sp_n).tFFFFFFFE.u3);
			(ss->*sp_n).t0000.u2 = (uint16) ss;
			(ss->*sp_n).tFFFFFFFE.u2 = (uint16) (bp_n - 110);
			Eq_n ax_n = fn0800-283D(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out dx_n);
			(ss->*sp_n).t0000.u2 = (uint16) dx_n;
			(ss->*sp_n).tFFFFFFFE.u2 = (uint16) ax_n;
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) ss;
			(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (bp_n - 0x84);
			Eq_n ax_n = fn0800-2931((ss->*sp_n).tFFFFFFFA.u3, (ss->*sp_n).tFFFFFFFE.u3, out dx_n);
			(ss->*bp_n).tFFFFFFFA.u2 = (uint16) dx_n;
			(ss->*bp_n).tFFFFFFF8.u2 = (uint16) ax_n;
			Mem898[ss:sp_n + 0x00:word16] = Mem895[ds_n:10705:word16];
			Mem901[ss:sp_n + -2:word16] = Mem898[ds_n:10703:word16];
			Eq_n dx_ax_n = fn0800-4194(ds_n, (ss->*sp_n).tFFFFFFFE.u3);
			Mem918[ds_n:0x29E9:word16] = SLICE(dx_ax_n - 0x04, word16, 16);
			Mem919[ds_n:10727:word16] = SLICE(dx_ax_n, word16, 0) - 0x04;
			Eq_n ax_n = fn0800-8C8A(CONVERT(Mem919[ds_n:0x29E9:word16], int16, int32), 0x08, out cl_n, out dx_n);
			Eq_n es_di_n;
			es_di_n.u3 = (ss->*bp_n).tFFFFFFF8.u3;
			(ss->*sp_n).t0000.u2 = (uint16) ax_n;
			struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
			byte Eq_n::* di_n = (word16) es_di_n;
			word16 cx_n = ~0x00;
			while (cx_n != 0x00)
			{
				++di_n;
				--cx_n;
				if (es_n->*di_n != 0x00)
					break;
			}
			word16 cx_n = ~cx_n;
			byte Eq_n::* di_n = di_n - cx_n;
			bool v100_n = di_n == &Eq_n::b0000;
			while (cx_n != 0x00)
			{
				v100_n = es_n->*di_n == 0x00;
				++di_n;
				--cx_n;
				if (es_n->*di_n != 0x00)
					break;
			}
			if (!v100_n)
			{
				di_n = &Eq_n::b0001;
				es_n = 0x00;
			}
			es_n->*di_n = (ss->*sp_n).t0000.u0;
			Eq_n es_di_n;
			es_di_n.u3 = (ss->*bp_n).tFFFFFFF8.u3;
			Mem1012[ss:sp_n + 0x00:word16] = Mem996[ds_n:0x29E9:word16];
			struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
			byte Eq_n::* di_n = (word16) es_di_n;
			word16 cx_n = ~0x00;
			while (cx_n != 0x00)
			{
				++di_n;
				--cx_n;
				if (es_n->*di_n != 0x00)
					break;
			}
			word16 cx_n = ~cx_n;
			struct Eq_n Eq_n::* di_n = di_n - cx_n;
			bool v104_n = di_n == &Eq_n::t0000;
			while (cx_n != 0x00)
			{
				v104_n = (es_n->*di_n).b0000 == 0x00;
				++di_n;
				--cx_n;
				if ((es_n->*di_n).b0000 != 0x00)
					break;
			}
			if (!v104_n)
			{
				di_n = &Eq_n::t0001;
				es_n = 0x00;
			}
			di_n[1] = (struct Eq_n) (ss->*sp_n).t0000.u0;
			Eq_n ax_n = fn0800-8C8A(Mem1074[ds_n:10727:int32], 0x08, out cl_n, out dx_n);
			Eq_n es_di_n;
			es_di_n.u3 = (ss->*bp_n).tFFFFFFF8.u3;
			(ss->*sp_n).t0000.u2 = (uint16) ax_n;
			struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
			byte Eq_n::* di_n = (word16) es_di_n;
			word16 cx_n = ~0x00;
			while (cx_n != 0x00)
			{
				++di_n;
				--cx_n;
				if (es_n->*di_n != 0x00)
					break;
			}
			word16 cx_n = ~cx_n;
			struct Eq_n Eq_n::* di_n = di_n - cx_n;
			bool v108_n = di_n == &Eq_n::t0000;
			while (cx_n != 0x00)
			{
				v108_n = (es_n->*di_n).b0000 == 0x00;
				++di_n;
				--cx_n;
				if ((es_n->*di_n).b0000 != 0x00)
					break;
			}
			if (!v108_n)
			{
				di_n = &Eq_n::t0001;
				es_n = 0x00;
			}
			di_n[2] = (struct Eq_n) (ss->*sp_n).t0000.u0;
			Eq_n es_di_n;
			es_di_n.u3 = (ss->*bp_n).tFFFFFFF8.u3;
			struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
			byte Eq_n::* di_n = (word16) es_di_n;
			word16 cx_n = ~0x00;
			while (cx_n != 0x00)
			{
				++di_n;
				--cx_n;
				if (es_n->*di_n != 0x00)
					break;
			}
			word16 cx_n = ~cx_n;
			struct Eq_n Eq_n::* di_n = di_n - cx_n;
			bool v112_n = di_n == &Eq_n::t0000;
			while (cx_n != 0x00)
			{
				v112_n = (es_n->*di_n).b0000 == 0x00;
				++di_n;
				--cx_n;
				if ((es_n->*di_n).b0000 != 0x00)
					break;
			}
			if (!v112_n)
			{
				di_n = &Eq_n::t0001;
				es_n = 0x00;
			}
			Mem1225[es_n:di_n + 0x03:byte] = Mem1160[ds_n:10727:byte];
			Mem1231[ds_n:0x2A05:word16] = 0x00;
			Mem1232[ds_n:0x2A03:word16] = 0x00;
			Mem1246[ss:sp_n + 0x00:word16] = Mem1232[ds_n:0x29E5:word16];
			Mem1249[ss:sp_n + -2:word16] = Mem1246[ds_n:0x29E3:word16];
			Eq_n dx_ax_n = fn0800-4194(ds_n, (ss->*sp_n).tFFFFFFFE.u3);
			Mem1261[ds_n:0x2A09:word16] = SLICE(dx_ax_n, word16, 16);
			Mem1262[ds_n:0x2A07:word16] = SLICE(dx_ax_n, word16, 0);
			(ss->*sp_n).t0000.u2 = (uint16) 0x00;
			Mem1271[ss:sp_n + -2:word16] = Mem1268[ds_n:0x29E9:word16];
			Mem1274[ss:sp_n + -4:word16] = Mem1271[ds_n:10727:word16];
			Mem1277[ss:sp_n + -6:word16] = Mem1274[ds_n:10721:word16];
			Mem1280[ss:sp_n + -8:word16] = Mem1277[ds_n:10719:word16];
			word16 cx_n;
			fn0800_ACB3(ds_n, (ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3, (ss->*sp_n).t0000.u2, out cx_n);
			word16 di_n = 0x01;
			si_n.u0 = 0x00;
			struct Eq_n Eq_n::* sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0000 + 2);
			if (Mem1280[ds_n:0x2A09:word16] >=u 0x00 && (Mem1280[ds_n:0x2A09:word16] >u 0x00 || Mem1280[ds_n:0x2A07:word16] >u 0x12) && Mem1280[ds_n:0x2A21:word16] != 0x00)
			{
				Mem1305[ss:sp_n + 0x00:word16] = Mem1280[ds_n:0x29E5:word16];
				Mem1308[ss:sp_n + -2:word16] = Mem1305[ds_n:0x29E3:word16];
				int32 dx_ax_n = fn0800-8CAA(fn0800-3F58(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out di_n, out ds_n), 0x08);
				sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0000 + 2);
				word16 ax_n = (word16) dx_ax_n;
				if (SLICE(dx_ax_n, word16, 16) != 0x52 || ax_n != 0x4E43)
				{
					Mem1343[ss:sp_n + 0x00:word16] = Mem1308[ds_n:0x2A09:word16];
					Mem1346[ss:sp_n + -2:word16] = Mem1343[ds_n:0x2A07:word16];
					Mem1349[ss:sp_n + -4:word16] = Mem1346[ds_n:0x2A09:word16];
					Mem1352[ss:sp_n + -6:word16] = Mem1349[ds_n:0x2A07:word16];
					Eq_n sp_n;
					sp_n.u0 = <invalid>;
					bp_n = fn0800-75EA(ds_n, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3, out si_n, out ds_n);
					sp_n = (struct Eq_n Eq_n::*) &sp_n.u5->t0008.u0;
					Eq_n ax_n = Mem1352[ds_n:0x2A05:word16];
					Eq_n dx_n = Mem1352[ds_n:0x2A03:word16];
					word16 ax_n;
					if (ax_n >=u Mem1352[ds_n:0x2A09:word16] && (ax_n != Mem1352[ds_n:0x2A09:word16] || dx_n >=u Mem1352[ds_n:0x2A07:word16]))
						ax_n = 0x01;
					else
						ax_n = 0x00;
					di_n = ax_n;
					if (ax_n != 0x00)
					{
						(ss->*sp_n.u5).t0006.u2 = (uint16) 0x01;
						ui32 ax_dx_n = -Mem1395[ds_n:0x2A03:ui32];
						(ss->*sp_n.u5).t0004.u1.u2 = SLICE(ax_dx_n, word16, 16);
						(ss->*sp_n.u5).t0002.u1.u2 = (uint16) (word16) ax_dx_n;
						Mem1412[ss:sp_n + 0x00:word16] = Mem1409[ds_n:10721:word16];
						Mem1415[ss:sp_n + -2:word16] = Mem1412[ds_n:10719:word16];
						word16 cx_n;
						fn0800_ACB3(ds_n, ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0002.u1.u3, (ss->*sp_n.u5).t0006.u2, out cx_n);
						sp_n = (struct Eq_n Eq_n::*) &sp_n.u5->t0008.u0;
					}
				}
			}
			if (di_n != 0x00)
			{
				Eq_n dx_n = Mem1436[ds_n:0x2A07:word16];
				Mem1442[ds_n:0x2A05:word16] = Mem1436[ds_n:0x2A09:word16];
				Mem1443[ds_n:0x2A03:word16] = dx_n;
				struct Eq_n Eq_n::* sp_n = sp_n - 2;
				Mem1448[ss:sp_n + 0x00:word16] = Mem1443[ds_n:0x29E5:word16];
				Mem1451[ss:sp_n + -2:word16] = Mem1448[ds_n:0x29E3:word16];
				fn0800_BA67(ds_n, (ss->*sp_n).tFFFFFFFE.u3);
				if (Mem1451[ds_n:0x2A09:word16] >=u 0x00 && (Mem1451[ds_n:0x2A09:word16] != 0x00 || Mem1451[ds_n:0x2A07:word16] >=u 0x12))
				{
					Mem1474[ss:sp_n + 0x00:word16] = Mem1451[ds_n:0x29E5:word16];
					Mem1477[ss:sp_n + -2:word16] = Mem1474[ds_n:0x29E3:word16];
					int32 dx_ax_n = fn0800-8CAA(fn0800-3F58(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out di_n, out ds_n), 0x08);
					word16 ax_n = (word16) dx_ax_n;
					if (SLICE(dx_ax_n, word16, 16) == 0x52 && ax_n == 0x4E43)
						goto l0800_nE;
				}
				struct Eq_n Eq_n::* sp_n = sp_n - 2;
				Mem1512[ss:sp_n + 0x00:word16] = Mem1507[ds_n:10705:word16];
				Mem1515[ss:sp_n + -2:word16] = Mem1512[ds_n:10703:word16];
				(ss->*sp_n).tFFFFFFFC.u2 = (uint16) 21070;
				(ss->*sp_n).tFFFFFFFA.u2 = (uint16) 0x4300;
				Eq_n ds_n = fn0800-409C(ds_n, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3);
				Mem1537[ss:sp_n + 0x00:word16] = Mem1521[ds_n:10705:word16];
				Mem1540[ss:sp_n + -2:word16] = Mem1537[ds_n:10703:word16];
				Mem1543[ss:sp_n + -4:word16] = Mem1540[ds_n:0x2A09:word16];
				Mem1546[ss:sp_n + -6:word16] = Mem1543[ds_n:0x2A07:word16];
				ds_n = fn0800-409C(ds_n, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3);
l0800_nE:
				struct Eq_n Eq_n::* sp_n = sp_n - 2;
				Mem1566[ss:sp_n + 0x00:word16] = Mem1561[ds_n:0x2A09:word16];
				Mem1569[ss:sp_n + -2:word16] = Mem1566[ds_n:0x2A07:word16];
				Mem1572[ss:sp_n + -4:word16] = Mem1569[ds_n:10705:word16];
				Mem1575[ss:sp_n + -6:word16] = Mem1572[ds_n:10703:word16];
				Mem1578[ss:sp_n + -8:word16] = Mem1575[ds_n:0x29E5:word16];
				Mem1581[ss:sp_n + -0x0A:word16] = Mem1578[ds_n:0x29E3:word16];
				Eq_n sp_n;
				sp_n.u0 = <invalid>;
				word16 si_n;
				bp_n = fn0800-3B0A(ds_n, (ss->*sp_n).tFFFFFFFE.u2, (ss->*sp_n).t0000.u2, out si_n, out ds_n);
				sp_n = (struct Eq_n Eq_n::*) &sp_n.u5->t000C.u0;
				si_n.u0 = 0x02;
			}
			sp_n = sp_n - 2;
			Mem1605[ss:sp_n + 0x00:word16] = Mem1600[ds_n:10705:word16];
			Mem1608[ss:sp_n + -2:word16] = Mem1605[ds_n:10703:word16];
			Mem1611[ss:sp_n + -4:word16] = Mem1608[ds_n:10733:word16];
			Mem1614[ss:sp_n + -6:word16] = Mem1611[ds_n:10731:word16];
			Eq_n ds_n = fn0800-409C(ds_n, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3);
			Mem1630[ss:sp_n + 0x00:word16] = Mem1614[ds_n:0x29E5:word16];
			Mem1633[ss:sp_n + -2:word16] = Mem1630[ds_n:0x29E3:word16];
			fn0800_A614(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out ds_n);
			(ss->*sp_n).t0000.u2 = (uint16) ds_n;
			(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x4541;
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) si_n;
			byte ch_n = SLICE(fn0800-0ABC(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out dx_n), byte, 8);
			es_bx_n = Mem1659[ds_n:11857:segptr32];
			dx_n.u2 = (uint16) *((word32) es_bx_n + 5);
			sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0000 + 2);
			bx_n = (word16) es_bx_n;
			cx_n = SEQ(ch_n, 0x08);
		} while ((word16) dx_n.u2 + ((uint16) ((es_bx_n.u5)->t0004).u0 << 0x08) < ~0x73);
		(ss->*sp_n).t0000.u2 = (uint16) ds_n;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x0952;
		word16 di_n;
		fn0800_B2EF(cx_n, dx_n, bx_n, ds_n, (ss->*sp_n).tFFFFFFFE.u3, out di_n);
		sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0000 + 2);
l0800_nA9:
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		Mem1709[ss:sp_n + 0x00:word16] = Mem1704[ds_n:10717:word16];
		Mem1712[ss:sp_n + -2:word16] = Mem1709[ds_n:10715:word16];
		Eq_n ds_n;
		fn0800_A614(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out ds_n);
		(ss->*sp_n).t0000.u2 = (uint16) ds_n;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x4477;
		fn0800-8F7F(ds_n, (ss->*sp_n).tFFFFFFFE.u3);
		word16 Eq_n::* bp_n = fn0800-1E5E(ds_n, out ds_n);
		Mem1754[ss:sp_n + 0x00:word16] = Mem1730[ds_n:10705:word16];
		Mem1757[ss:sp_n + -2:word16] = Mem1754[ds_n:10703:word16];
		struct Eq_n * ds_n;
		fn0800_A614(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out ds_n);
		word16 bp_n = ss->*bp_n;
		dsOut = ds_n;
		return bp_n;
	}
	else
	{
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		Mem1780[ss:sp_n + 0x00:word16] = Mem1777[ds_n:10705:word16];
		Mem1783[ss:sp_n + -2:word16] = Mem1780[ds_n:10703:word16];
		struct Eq_n * ds_n;
		fn0800_A614(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out ds_n);
		word16 bp_n = (ss->*bp_n).w0000;
		dsOut = ds_n;
		return bp_n;
	}
}

// 0800:18D9: Register word16 fn0800-18D9(Register Eq_n cx, Register Eq_n dx, Register Eq_n ds, Register out (ptr16 Eq_n) dsOut)
// Called from:
//      main
word16 fn0800-18D9(Eq_n cx, Eq_n dx, Eq_n ds, struct Eq_n & dsOut)
{
	Eq_n ds_n;
	Eq_n ds_n;
	Eq_n si_n;
	struct Eq_n Eq_n::* bp_n;
	Eq_n dx_n;
	Eq_n ds_n;
	word16 cx_n;
	word16 di_n;
	fn0800_B2EF(cx, dx, Mem18[ds:0x2A25:word16] << 0x02, ds, SEQ(ds, 2412), out di_n);
	Eq_n dx_ax_n = fn0800_AA7E(ds, SEQ(ds, 0x4348), SEQ(ds, 2429), out cx_n, out ds_n);
	Eq_n dx_n;
	dx_n.u3 = SLICE(dx_ax_n, word16, 16);
	Mem67[ds_n:10705:word16] = dx_n;
	Eq_n ax_n = (word16) dx_ax_n;
	Mem68[ds_n:10703:word16] = ax_n;
	if (dx_ax_n == 0x00)
	{
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		word16 si_n;
		word16 di_n;
		fn0800-0D24(ds_n, 0x07, SEQ(ds_n, 0x4348), out cx_n, out dx_n, out bx_n, out si_n, out di_n, out ds_n);
	}
	Eq_n cx_n = fn0800-1CF6(ds_n, 0x01, out dx_n, out bp_n, out si_n, out ds_n);
	Eq_n sp_n;
	sp_n.u0 = <invalid>;
	Eq_n ss;
	(ss->*sp_n.u5).t0000.u1.u2 = (uint16) 0x00;
	(ss->*((word32) sp_n - 2)).u0 = 0x00;
	fn0800-2DBF(ds_n, ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0000.u1.u2);
	struct Eq_n Eq_n::* sp_n = (struct Eq_n Eq_n::*) &sp_n.u5->t0002.u0;
	struct Eq_n Eq_n::* sp_n;
	Eq_n ds_n;
	while (true)
	{
		sp_n = sp_n - 2;
		(ss->*sp_n).t0000.u2 = (uint16) ss;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) (bp_n - 110);
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) ss;
		(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (bp_n - 8);
		(ss->*sp_n).tFFFFFFF8.u2 = (uint16) ss;
		(ss->*sp_n).tFFFFFFF6.u0 = (word16) (bp_n - 4);
		if (fn0800-29C5(cx_n, dx_n, si_n, ds_n, (ss->*sp_n).tFFFFFFF6.u1, (ss->*sp_n).tFFFFFFFA.u3, (ss->*sp_n).tFFFFFFFE.u3, out ds_n) == 0x00)
			break;
		(ss->*sp_n).t0000.u2 = (uint16) ss;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) (bp_n - 110);
		fn0800-0C93(ds_n, (ss->*sp_n).tFFFFFFFE.u3);
		(ss->*sp_n).t0000.u2 = (ss->*bp_n).tFFFFFFFA.u2;
		(ss->*sp_n).tFFFFFFFE.u2 = (ss->*bp_n).tFFFFFFF8.u2;
		fn0800-23EC(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out bp_n, out si_n, out ds_n);
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFFA.u2;
		(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).tFFFFFFF8.u2;
		fn0800-22FE(ds_n, (ss->*sp_n.u5).t0000.u1.u3);
		Eq_n es_di_n;
		es_di_n.u3 = (ss->*bp_n).tFFFFFFFC.u3;
		struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
		byte Eq_n::* di_n = (word16) es_di_n + 0x02;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		word16 cx_n = ~cx_n;
		byte Eq_n::* di_n = di_n - cx_n;
		bool v36_n = di_n == &Eq_n::b0000;
		while (cx_n != 0x00)
		{
			v36_n = es_n->*di_n == 0x00;
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		if (!v36_n)
		{
			di_n = &Eq_n::b0001;
			es_n = 0x00;
		}
		if (es_n->*di_n == 0x00)
		{
			Eq_n dx_n = Mem252[ds_n:11857:word16];
			if (Mem252[ds_n:11859:word16] != Mem252[ss:bp_n + -2:word16] || &((dx_n.u5)->t0008).u0 != ((ss->*bp_n).tFFFFFFFC).u2)
			{
				(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFFE.u2;
				(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).tFFFFFFFC.u2;
				fn0800-2201(ds_n, (ss->*sp_n.u5).t0000.u1.u3);
			}
		}
		(ss->*sp_n.u5).t0002.u1.u2 = (uint16) ss;
		(ss->*sp_n.u5).t0000.u1.u2 = (uint16) (bp_n - 110);
		(ss->*((word32) sp_n - 2)).u0 = 0x0D;
		cx_n = fn0800-0ABC(ds_n, ss->*sp_n.u4, out dx_n);
		sp_n = (struct Eq_n Eq_n::*) &sp_n.u5->t0004.u0;
	}
	word16 Eq_n::* bp_n = fn0800-1E5E(ds_n, out ds_n);
	Mem185[ss:sp_n + 0x00:word16] = Mem147[ds_n:10705:word16];
	Mem188[ss:sp_n + -2:word16] = Mem185[ds_n:10703:word16];
	struct Eq_n * ds_n;
	fn0800_A614(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out ds_n);
	word16 bp_n = ss->*bp_n;
	dsOut = ds_n;
	return bp_n;
}

// 0800:19EE: Register Eq_n fn0800-19EE(Register Eq_n cx, Register Eq_n dx, Register Eq_n ds, Register out Eq_n dsOut)
// Called from:
//      main
Eq_n fn0800-19EE(Eq_n cx, Eq_n dx, Eq_n ds, union Eq_n & dsOut)
{
	Eq_n ds_n;
	Eq_n ds_n;
	word16 si_n;
	Eq_n dx_n;
	word16 cx_n;
	Eq_n ds_n;
	Eq_n si_n;
	struct Eq_n Eq_n::* bp_n;
	Eq_n dx_n;
	Eq_n ds_n;
	word16 cx_n;
	word16 di_n;
	fn0800_B2EF(cx, dx, Mem21[ds:0x2A25:word16] << 0x02, ds, SEQ(ds, 0x0986), out di_n);
	Eq_n dx_ax_n = fn0800_AA7E(ds, SEQ(ds, 0x4348), SEQ(ds, 0x0997), out cx_n, out ds_n);
	Eq_n dx_n;
	dx_n.u3 = SLICE(dx_ax_n, word16, 16);
	Mem70[ds_n:10705:word16] = dx_n;
	Eq_n ax_n = (word16) dx_ax_n;
	Mem71[ds_n:10703:word16] = ax_n;
	if (dx_ax_n == 0x00)
	{
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		word16 si_n;
		word16 di_n;
		fn0800-0D24(ds_n, 0x07, SEQ(ds_n, 0x4348), out cx_n, out dx_n, out bx_n, out si_n, out di_n, out ds_n);
	}
	Eq_n ss;
	if (Mem101[ds_n:0x2A27:word16] == Mem101[ds_n:9882:word16])
	{
		Eq_n es_bx_n = Mem110[ds_n:9884:segptr32];
		es_bx_n.u0->t0006.u2 = (uint16) ss;
		mp16 fp;
		es_bx_n.u0->w0004 = fp - 0x0E;
		Mem119[ds_n:0x2A27:word16] = 0x01;
		Mem120[ds_n:9882:word16] = 0x02;
		Mem121[ds_n:10779:word16] = 0x01;
	}
	fn0800-2DBF(ds_n, 0x01, 0x00);
	Eq_n sp_n;
	sp_n.u0 = <invalid>;
	Eq_n cx_n = fn0800-1CF6(ds_n, 0x01, out dx_n, out bp_n, out si_n, out ds_n);
	Eq_n sp_n;
	sp_n.u3 = &sp_n.u5->t0002.u0;
	if (Mem140[ds_n:0x2A25:word16] == 0x07)
	{
		(ss->*sp_n.u5).t0000.u1.u2 = (uint16) ds_n;
		(ss->*((word32) sp_n - 2)).u0 = 0x099B;
		ss->*((word32) sp_n - 4) = ds_n;
		(ss->*((word32) sp_n - 6)).u0 = 0x44DC;
		si_n = fn0800-37BE(cx_n, dx_n, ds_n, ss->*((word32) sp_n - 6));
		sp_n.u3 = &sp_n.u5->t0002.u0;
	}
	struct Eq_n Eq_n::* sp_n;
	Eq_n ds_n;
	while (true)
	{
		sp_n = sp_n - 2;
		(ss->*sp_n).t0000.u2 = (uint16) ss;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) (bp_n - 114);
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) ss;
		(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (bp_n - 8);
		(ss->*sp_n).tFFFFFFF8.u2 = (uint16) ss;
		(ss->*sp_n).tFFFFFFF6.u0 = (word16) (bp_n - 4);
		if (fn0800-29C5(cx_n, dx_n, si_n, ds_n, (ss->*sp_n).tFFFFFFF6.u1, (ss->*sp_n).tFFFFFFFA.u3, (ss->*sp_n).tFFFFFFFE.u3, out ds_n) == 0x00)
			break;
		(ss->*sp_n).t0000.u2 = (uint16) ss;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) (bp_n - 114);
		fn0800-0C93(ds_n, (ss->*sp_n).tFFFFFFFE.u3);
		(ss->*sp_n).t0000.u2 = (ss->*bp_n).tFFFFFFFA.u2;
		(ss->*sp_n).tFFFFFFFE.u2 = (ss->*bp_n).tFFFFFFF8.u2;
		Eq_n ds_n = fn0800-24FE(ds_n, (ss->*sp_n).tFFFFFFFE.u3);
		(ss->*sp_n).t0000.u2 = (uint16) 0x00;
		Eq_n es_di_n;
		es_di_n.u3 = (ss->*bp_n).tFFFFFFF8.u3;
		struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
		byte Eq_n::* di_n = (word16) es_di_n;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		word16 cx_n = ~cx_n;
		int8 Eq_n::* di_n = di_n - cx_n;
		bool v42_n = di_n == &Eq_n::b0000;
		while (cx_n != 0x00)
		{
			v42_n = es_n->*di_n == 0x00;
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		if (!v42_n)
		{
			di_n = &Eq_n::b0001;
			es_n = 0x00;
		}
		Eq_n es_di_n;
		es_di_n.u3 = (ss->*bp_n).tFFFFFFF8.u3;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) ((int16) (es_n->*di_n) << 0x08);
		struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
		byte Eq_n::* di_n = (word16) es_di_n;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		word16 cx_n = ~cx_n;
		struct Eq_n Eq_n::* di_n = di_n - cx_n;
		bool v46_n = di_n == &Eq_n::t0000;
		while (cx_n != 0x00)
		{
			v46_n = (es_n->*di_n).b0000 == 0x00;
			++di_n;
			--cx_n;
			if ((es_n->*di_n).b0000 != 0x00)
				break;
		}
		if (!v46_n)
		{
			di_n = &Eq_n::t0001;
			es_n = 0x00;
		}
		Eq_n es_di_n;
		es_di_n.u3 = (ss->*bp_n).tFFFFFFF8.u3;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) ((ss->*sp_n).tFFFFFFFE.u2 + (uint16) di_n[1]);
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) 0x00;
		struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
		byte Eq_n::* di_n = (word16) es_di_n;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		word16 cx_n = ~cx_n;
		struct Eq_n Eq_n::* di_n = di_n - cx_n;
		bool v50_n = di_n == &Eq_n::t0000;
		while (cx_n != 0x00)
		{
			v50_n = (es_n->*di_n).b0000 == 0x00;
			++di_n;
			--cx_n;
			if ((es_n->*di_n).b0000 != 0x00)
				break;
		}
		if (!v50_n)
		{
			di_n = &Eq_n::t0001;
			es_n = 0x00;
		}
		Eq_n es_di_n;
		es_di_n.u3 = (ss->*bp_n).tFFFFFFF8.u3;
		(ss->*sp_n).tFFFFFFFA.u2 = (uint16) ((int16) di_n[2] << 0x08);
		struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
		byte Eq_n::* di_n = (word16) es_di_n;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		word16 cx_n = ~cx_n;
		struct Eq_n Eq_n::* di_n = di_n - cx_n;
		bool v54_n = di_n == &Eq_n::t0000;
		while (cx_n != 0x00)
		{
			v54_n = (es_n->*di_n).b0000 == 0x00;
			++di_n;
			--cx_n;
			if ((es_n->*di_n).b0000 != 0x00)
				break;
		}
		if (!v54_n)
		{
			di_n = &Eq_n::t0001;
			es_n = 0x00;
		}
		uint32 dx_ax_n = (ss->*sp_n).tFFFFFFFC.u3 + (uint32) (((ss->*sp_n).tFFFFFFFA).u2 + (uint16) di_n[3]);
		(ss->*sp_n).tFFFFFFFE.u2 = SLICE(dx_ax_n, word16, 16);
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) (word16) dx_ax_n;
		Mem612[ss:sp_n + -6:word16] = Mem589[ds_n:10705:word16];
		Mem615[ss:sp_n + -8:word16] = Mem612[ds_n:10703:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, (ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3, (ss->*sp_n).t0000.u2, out cx_n);
		if (Mem615[ds_n:0x2A25:word16] != 0x07)
		{
			(ss->*sp_n).t0000.u2 = (uint16) ds_n;
			Eq_n es_n;
			es_n.u6 = (ss->*sp_n).t0000.u6;
			(ss->*sp_n).t0000.u2 = (uint16) es_n;
			(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x44DC;
			byte Eq_n::* di_n = 17022;
			word16 cx_n = ~0x00;
			while (cx_n != 0x00)
			{
				++di_n;
				--cx_n;
				if (es_n->*di_n != 0x00)
					break;
			}
			Eq_n di_n;
			di_n.u2 = (ss->*sp_n).tFFFFFFFE.u2;
			Eq_n es_n;
			es_n.u6 = (ss->*sp_n).t0000.u6;
			(ss->*sp_n).t0000.u2 = (uint16) ds_n;
			cu16 cx_n = ~cx_n;
			<unknown>* di_n = di_n - cx_n;
			uint32 size_n = (cx_n >> 0x01) *32 0x02;
			memcpy(&(es_n->*di_n.u3), di_n, size_n);
			memcpy(&(es_n->*(di_n.u3 + (word16) size_n)), &(es_n->*((char *) di_n + (word16) size_n)), cond(cx_n >> 0x01) & 0x02);
			Eq_n ds_n;
			ds_n.u6 = (ss->*sp_n).t0000.u6;
			if (Mem674[ds_n:0x2A25:word16] == 0x08)
			{
				if (Mem674[ds_n:17022:byte] != 0x00 && (ss->*bp_n).bFFFFFF8E == 0x5C)
				{
					(ss->*sp_n).t0000.u2 = (uint16) ss;
					(ss->*sp_n).tFFFFFFFE.u2 = (uint16) (bp_n - 113);
					(ss->*sp_n).tFFFFFFFC.u2 = (uint16) ds_n;
					Eq_n es_n;
					es_n.u6 = (ss->*sp_n).tFFFFFFFC.u6;
					byte Eq_n::* di_n = 0x44DC;
					word16 cx_n = ~0x00;
					while (cx_n != 0x00)
					{
						++di_n;
						--cx_n;
						if (es_n->*di_n != 0x00)
							break;
					}
					word16 cx_n = ~cx_n;
					byte Eq_n::* di_n = di_n - cx_n;
					bool v62_n = di_n == 0x00;
					while (cx_n != 0x00)
					{
						v62_n = es_n->*di_n == 0x00;
						++di_n;
						--cx_n;
						if (es_n->*di_n != 0x00)
							break;
					}
					if (!v62_n)
					{
						di_n = 0x01;
						es_n.u0 = 0x00;
					}
					(ss->*sp_n).tFFFFFFFC.u2 = (uint16) es_n;
					(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (di_n - 0x01);
					word16 bx_n;
					fn0800-3509((ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u6, (ss->*sp_n).tFFFFFFFE.u3, out bx_n);
				}
				else
				{
					(ss->*sp_n).t0000.u2 = (uint16) ss;
					(ss->*sp_n).tFFFFFFFE.u2 = (uint16) (bp_n - 114);
					(ss->*sp_n).tFFFFFFFC.u2 = (uint16) ds_n;
					Eq_n es_n;
					es_n.u6 = (ss->*sp_n).tFFFFFFFC.u6;
					byte Eq_n::* di_n = 0x44DC;
					word16 cx_n = ~0x00;
					while (cx_n != 0x00)
					{
						++di_n;
						--cx_n;
						if (es_n->*di_n != 0x00)
							break;
					}
					word16 cx_n = ~cx_n;
					byte Eq_n::* di_n = di_n - cx_n;
					bool v58_n = di_n == 0x00;
					while (cx_n != 0x00)
					{
						v58_n = es_n->*di_n == 0x00;
						++di_n;
						--cx_n;
						if (es_n->*di_n != 0x00)
							break;
					}
					if (!v58_n)
					{
						di_n = 0x01;
						es_n.u0 = 0x00;
					}
					(ss->*sp_n).tFFFFFFFC.u2 = (uint16) es_n;
					(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (di_n - 0x01);
					word16 bx_n;
					fn0800-3509((ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u6, (ss->*sp_n).tFFFFFFFE.u3, out bx_n);
				}
			}
			struct Eq_n Eq_n::* sp_n = sp_n - 2;
			(ss->*sp_n).t0000.u2 = (uint16) ds_n;
			(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x44DC;
			word16 dx_n;
			word16 si_n;
			fn0800-3678(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out dx_n, out si_n, out ds_n);
			(ss->*sp_n).t0000.u2 = (uint16) ss;
			(ss->*sp_n).tFFFFFFFE.u2 = (uint16) (bp_n - 114);
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) ds_n;
			Eq_n es_n;
			es_n.u6 = (ss->*sp_n).tFFFFFFFC.u6;
			byte Eq_n::* di_n = 0x44DC;
			word16 cx_n = ~0x00;
			while (cx_n != 0x00)
			{
				++di_n;
				--cx_n;
				if (es_n->*di_n != 0x00)
					break;
			}
			word16 cx_n = ~cx_n;
			byte Eq_n::* di_n = di_n - cx_n;
			bool v66_n = di_n == 0x00;
			while (cx_n != 0x00)
			{
				v66_n = es_n->*di_n == 0x00;
				++di_n;
				--cx_n;
				if (es_n->*di_n != 0x00)
					break;
			}
			if (!v66_n)
			{
				di_n = 0x01;
				es_n.u0 = 0x00;
			}
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) es_n;
			(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (di_n - 0x01);
			word16 dx_n;
			fn0800-35A3((ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u6, (ss->*sp_n).tFFFFFFFE.u3, out dx_n);
		}
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		(ss->*sp_n).t0000.u2 = (uint16) ds_n;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 2472;
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) ds_n;
		(ss->*sp_n).tFFFFFFFA.u2 = (uint16) 0x44DC;
		Eq_n ax_n = fn0800-4234(ds_n, (ss->*sp_n).tFFFFFFFA.u3, (ss->*sp_n).tFFFFFFFE.u3, out cx_n, out dx_n, out si_n, out ds_n);
		Mem1021[ds_n:10721:word16] = dx_n;
		Mem1022[ds_n:10719:word16] = ax_n;
		Eq_n dx_n = Mem1022[ds_n:10703:word16];
		Mem1025[ds_n:0x29E5:word16] = Mem1022[ds_n:10705:word16];
		Mem1026[ds_n:0x29E3:word16] = dx_n;
		Eq_n ax_n = fn0800-5374(ds_n, out bp_n, out ds_n);
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		Mem1044[ss:sp_n + -2:word16] = Mem1026[ds_n:10721:word16];
		Mem1047[ss:sp_n + -4:word16] = Mem1044[ds_n:10719:word16];
		fn0800_A614(ds_n, ss->*((word32) sp_n - 4), out ds_n);
		si_n = ax_n;
		if (ax_n != 0x00)
		{
			ss->*((word32) sp_n - 2) = ds_n;
			(ss->*((word32) sp_n - 4)).u0 = 0x44DC;
			fn0800-8F7F(ds_n, ss->*((word32) sp_n - 4));
		}
		ss->*((word32) sp_n - 2) = ss;
		ss->*((word32) sp_n - 4) = bp_n - 114;
		ss->*((word32) sp_n - 6) = ax_n;
		cx_n = fn0800-0ABC(ds_n, ss->*((word32) sp_n - 4), out dx_n);
		sp_n = sp_n;
	}
	Mem223[ss:sp_n + 0x00:word16] = Mem198[ds_n:10705:word16];
	Mem226[ss:sp_n + -2:word16] = Mem223[ds_n:10703:word16];
	Eq_n ds_n;
	fn0800_A614(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out ds_n);
	if (Mem226[ds_n:0x2A25:word16] == 0x07)
	{
		(ss->*sp_n).t0000.u2 = (uint16) ds_n;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x44DC;
		fn0800-8F7F(ds_n, (ss->*sp_n).tFFFFFFFE.u3);
	}
	Eq_n bp_n;
	bp_n.u2 = (ss->*bp_n).t0000.u2;
	dsOut = ds_n;
	return bp_n;
}

// 0800:1CF6: Register word16 fn0800-1CF6(Register Eq_n ds, Stack Eq_n wArg02, Register out word16 dxOut, Register out word16 bpOut, Register out word16 siOut, Register out (ptr16 Eq_n) dsOut)
// Called from:
//      fn0800-12E2
//      fn0800-18D9
//      fn0800-19EE
word16 fn0800-1CF6(Eq_n ds, Eq_n wArg02, word16 & dxOut, word16 & bpOut, word16 & siOut, struct Eq_n & dsOut)
{
	uint8 cl_n;
	word16 Eq_n::* sp_n;
	struct Eq_n * ds_n;
	word16 si_n;
	word16 bp_n;
	word16 dx_n;
	struct Eq_n * ds_n;
	word16 si_n;
	word16 bp_n;
	word16 dx_n;
	Eq_n ds_n;
	word16 di_n;
	word16 cx_n;
	Eq_n ds_n;
	Eq_n ds_n;
	Eq_n ds_n;
	Mem19[ds:0x45A8:word16] = 0x00;
	Mem20[ds:0x45A6:word16] = 0x00;
	Mem21[ds:10733:word16] = 0x00;
	Mem22[ds:10731:word16] = 0x00;
	word16 cx_n;
	fn0800_ACB3(ds, Mem31[ds:10703:word32], ~0x03, 0x02, out cx_n);
	Eq_n dx_ax_n = fn0800-3E5D(ds, Mem37[ds:10703:word32], out ds_n);
	Mem69[ds_n:10733:word16] = SLICE(dx_ax_n, word16, 16);
	Mem70[ds_n:10731:word16] = SLICE(dx_ax_n, word16, 0);
	if (fn0800-4194(ds_n, Mem70[ds_n:10703:word32]) <u Mem76[ds_n:10731:word32])
	{
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		word16 si_n;
		word16 di_n;
		selector ds_n;
		fn0800-0D24(ds_n, 11, SEQ(ds_n, 0x4348), out cx_n, out dx_n, out bx_n, out si_n, out di_n, out ds_n);
	}
	Eq_n ds_n;
	word16 cx_n;
	fn0800_ACB3(ds_n, Mem133[ds_n:10703:word32], Mem126[ds_n:10731:word32], 0x00, out cx_n);
	Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem139[ds_n:10703:word32], out ds_n);
	word16 ax_n = (word16) dx_ax_n;
	if (SLICE(dx_ax_n, word16, 16) != 21070 || ax_n != 17217)
	{
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		word16 si_n;
		word16 di_n;
		selector ds_n;
		fn0800-0D24(ds_n, 11, SEQ(ds_n, 0x4348), out cx_n, out dx_n, out bx_n, out si_n, out di_n, out ds_n);
	}
	Eq_n ax_n = fn0800-3E27(ds_n, Mem201[ds_n:10703:word32], out cx_n, out di_n, out ds_n);
	word16 cx_n;
	word16 di_n;
	Eq_n ds_n;
	fn0800-3E27(ds_n, Mem209[ds_n:10703:word32], out cx_n, out di_n, out ds_n);
	if (wArg02 != 0x00)
	{
		Eq_n ax_n = fn0800-4311(ds_n, (uint32) ax_n, out dx_n, out bp_n, out si_n, out ds_n);
		ds_n->w2E53 = dx_n;
		ds_n->t2E51 = ax_n;
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		word16 sp_n = (word16) &sp_n.u5->t0004.u0;
	}
	else
	{
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		Eq_n ax_n = fn0800-4311(ds_n, 0xFFF0, out dx_n, out bp_n, out si_n, out ds_n);
		ds_n->w2E53 = dx_n;
		ds_n->t2E51 = ax_n;
		word16 sp_n = (word16) &sp_n.u5->t0004.u0;
	}
	struct Eq_n Eq_n::* sp_n = sp_n - 2;
	selector ss;
	(ss->*sp_n).t0000.u2 = (uint16) 0x00;
	Eq_n ds_n;
	Mem313[ss:sp_n + -2:word16] = Mem309[ds_n:10733:word16];
	Mem316[ss:sp_n + -4:word16] = Mem313[ds_n:10731:word16];
	Mem319[ss:sp_n + -6:word16] = Mem316[ds_n:10705:word16];
	Mem322[ss:sp_n + -8:word16] = Mem319[ds_n:10703:word16];
	word16 cx_n;
	fn0800_ACB3(ds_n, (ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3, (ss->*sp_n).t0000.u2, out cx_n);
	Mem336[ss:sp_n + 0x00:word16] = Mem322[ds_n:10705:word16];
	Mem339[ss:sp_n + -2:word16] = Mem336[ds_n:10703:word16];
	(ss->*sp_n).tFFFFFFFC.u2 = (uint16) 0x00;
	Eq_n si_n;
	(ss->*sp_n).tFFFFFFFA.u2 = (uint16) si_n;
	Mem351[ss:sp_n + -8:word16] = Mem348[ds_n:11859:word16];
	Mem354[ss:sp_n + -0x0A:word16] = Mem351[ds_n:11857:word16];
	word16 si_n;
	word16 di_n;
	Eq_n ds_n;
	fn0800-4110(ds_n, (ss->*sp_n).tFFFFFFF6.u3, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3, out si_n, out di_n, out ds_n);
	(ss->*sp_n).t0000.u2 = (uint16) 0x00;
	(ss->*sp_n).tFFFFFFFE.u2 = (uint16) (si_n - 0x08);
	Eq_n ax_n = Mem374[ds_n:11857:word16];
	Mem380[ss:sp_n + -4:word16] = Mem374[ds_n:11859:word16];
	(ss->*sp_n).tFFFFFFFA.u2 = (uint16) &ax_n.u5->t0008.u0;
	uint16 cx_n = (uint16) cl_n;
	word16 dx_n;
	struct Eq_n Eq_n::* bp_n;
	if (fn0800-2CCF(ds_n, (ss->*sp_n).tFFFFFFFA.u3, (ss->*sp_n).tFFFFFFFE.u2, (ss->*sp_n).t0000.u2, out cl_n, out dx_n) != (ss->*bp_n).wFFFFFFFE)
	{
		(ss->*sp_n).t0000.u2 = (uint16) ds_n;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x4348;
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) 0x0D;
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		word16 si_n;
		word16 di_n;
		selector ds_n;
		fn0800-0D24(ds_n, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3, out cx_n, out dx_n, out bx_n, out si_n, out di_n, out ds_n);
	}
	word16 si_n = ss->*sp_n;
	word16 bp_n = (ss->*bp_n).w0000;
	word16 dx_n;
	dxOut = dx_n;
	bpOut = bp_n;
	siOut = si_n;
	struct Eq_n * ds_n;
	dsOut = ds_n;
	word16 cx_n;
	return cx_n;
}

// 0800:1E5E: Register word16 fn0800-1E5E(Register Eq_n ds, Register out (ptr16 Eq_n) dsOut)
// Called from:
//      fn0800-12E2
//      fn0800-18D9
word16 fn0800-1E5E(Eq_n ds, struct Eq_n & dsOut)
{
	Eq_n ds_n;
	word16 di_n;
	Eq_n cx_n;
	word16 dx_n;
	byte cl_n;
	Eq_n es_bx_n = Mem7[ds:11857:segptr32];
	Eq_n ax_n = ((uint16) es_bx_n.u5->t0004.u0 << 0x08) + (uint16) (*((word32) es_bx_n + 5));
	cu16 ax_n = fn0800-2CCF(ds, SEQ(Mem28[ds:11859:word16], Mem28[ds:11857:word16] + 0x08), ax_n - 0x08, 0x00, out cl_n, out dx_n);
	Eq_n es_bx_n = Mem36[ds:11857:segptr32];
	es_bx_n.u5->t0006.u0 = (int8) (byte) (ax_n >> 0x08);
	((word32) es_bx_n + 7)->u3 = (byte) ax_n;
	word16 dx_n = Mem59[ds:10731:word16];
	word16 cx_n;
	fn0800_ACB3(ds, Mem70[ds:10703:word32], SEQ(SLICE(SEQ(Mem59[ds:10733:word16], dx_n) + 0x04, word16, 16), dx_n + 0x04), 0x00, out cx_n);
	Eq_n si_n = ax_n;
	Eq_n ax_n = fn0800-3E27(ds, Mem76[ds:10703:word32], out cx_n, out di_n, out ds_n);
	word16 bp;
	if (ax_n > ax_n)
		bp = fn0800-3BC3(cx_n, 0x00, ds_n, Mem167[ds_n:10703:word32], Mem161[ds_n:10731:word32], out si_n, out ds_n);
	else if (ax_n < ax_n)
		fn0800-3C99(ds_n, Mem127[ds_n:10703:word32], Mem124[ds_n:10731:word16], Mem121[ds_n:10733:word16], out bp, out si_n, out ds_n);
	word16 cx_n;
	fn0800_ACB3(ds_n, Mem206[ds_n:10703:word32], Mem199[ds_n:10731:word32], 0x00, out cx_n);
	word16 si_n;
	Eq_n ds_n;
	fn0800-4152(ds_n, Mem238[ds_n:11857:word32], si_n, 0x00, Mem212[ds_n:10703:word32], out si_n, out ds_n);
	word16 cx_n;
	word16 dx_n;
	word16 bx_n;
	struct Eq_n * ds_n;
	fn0800-4346(ds_n, Mem244[ds_n:11859:word16], out cx_n, out dx_n, out bx_n, out ds_n);
	dsOut = ds_n;
	return bp;
}

// 0800:1F5C: Register (memptr Eq_n Eq_n) fn0800-1F5C(Register Eq_n ds, Stack Eq_n ptrArg02, Register out Eq_n dxOut)
// Called from:
//      fn0800-12E2
<unknown> Eq_n::* fn0800-1F5C(Eq_n ds, Eq_n ptrArg02, union Eq_n & dxOut)
{
	struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
	byte Eq_n::* di_n = (word16) ptrArg02;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (es_n->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	Eq_n di_n = di_n - cx_n;
	bool v33_n = di_n == 0x00;
	while (cx_n != 0x00)
	{
		v33_n = es_n->*di_n == 0x3A;
		di_n = (word16) di_n + 1;
		--cx_n;
		if (es_n->*di_n != 0x3A)
			break;
	}
	if (!v33_n)
	{
		di_n.u0 = 0x01;
		es_n = 0x00;
	}
	if ((di_n - 0x01 | es_n) != 0x00)
	{
		struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
		byte Eq_n::* di_n = (word16) ptrArg02;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		word16 cx_n = ~cx_n;
		byte Eq_n::* di_n = di_n - cx_n;
		bool v37_n = di_n == &Eq_n::b0000;
		while (cx_n != 0x00)
		{
			v37_n = es_n->*di_n == 0x3A;
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x3A)
				break;
		}
		if (!v37_n)
		{
			di_n = &Eq_n::b0001;
			es_n = 0x00;
		}
		ptrArg02.u3 = &(es_n->*di_n);
	}
	Eq_n es_bx_n = Mem149[ds:11857:segptr32];
	uint16 ax_n = ((uint16) es_bx_n.u5->t0004.u0 << 0x08) + (uint16) (*((word32) es_bx_n + 5));
	struct Eq_n * wArg04_n = SLICE(ptrArg02, word16, 16);
	byte Eq_n::* wArg02_n = (word16) ptrArg02;
	byte bLoc08_n = (byte) ax_n;
	Eq_n ax_n = Mem164[ds:11859:word16];
	<unknown> Eq_n::* dx_n = Mem164[ds:11857:word16] + ax_n;
	struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
	byte Eq_n::* di_n = (word16) ptrArg02;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		byte Eq_n::* di_n;
		di_n = di_n + 1;
		--cx_n;
		di_n = di_n;
		if (es_n->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	struct Eq_n * ptrLoc06_n = SEQ(ax_n, dx_n);
	byte cl_n;
	word16 dx_n;
	Mem221[ptrLoc06_n + 0x00:byte] = SLICE(fn0800-8C8A(CONVERT(dx_n - Mem193[ds:11857:word16] + (cx_n + 0x03), word16, uint32), 0x08, out cl_n, out dx_n), byte, 0);
	byte bLoc0A_n = (byte) cx_n + 0x03;
	Mem230[ptrLoc06_n + 1:byte] = SLICE(dx_n, byte, 0) - Mem221[ds:11857:byte] + bLoc0A_n;
	byte Eq_n::* di_n = wArg02_n;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (wArg04_n->*di_n != 0x00)
			break;
	}
	cu16 cx_n = ~cx_n;
	<unknown>* di_n = di_n - cx_n;
	uint32 size_n = (cx_n >> 0x01) *32 0x02;
	memcpy(&(ax_n->*((char *) dx_n + 2)), di_n, size_n);
	memcpy(&(ax_n->*(((char *) dx_n + 2) + (word16) size_n)), &(wArg04_n->*((char *) di_n + (word16) size_n)), cond(cx_n >> 0x01) & 0x02);
	((char *) dx_n + (cx_n + 0x03))[-1] = 0x00;
	Eq_n es_bx_n = Mem307[ds:11857:segptr32];
	es_bx_n.u5->t0004.u0 = (int8) (byte) (ax_n + (cx_n + 0x03) >> 0x08);
	((word32) es_bx_n + 5)->u1 = bLoc08_n + bLoc0A_n;
	fn0800-2688(ds, (uint32) (cx_n + 0x03), 0x00);
	dxOut = ax_n;
	return dx_n;
}

// 0800:2085: Register byte fn0800-2085(Register Eq_n ds, Stack Eq_n ptrArg02, Stack Eq_n ptrArg06)
// Called from:
//      fn0800-12E2
byte fn0800-2085(Eq_n ds, Eq_n ptrArg02, Eq_n ptrArg06)
{
	struct Eq_n * psegArg04_n = SLICE(ptrArg02, selector, 16);
	byte Eq_n::* wArg02_n = (word16) ptrArg02;
	Eq_n es_bx_n = Mem15[ds:11857:segptr32];
	uint16 ax_n = ((uint16) es_bx_n.u5->t0004.u0 << 0x08) + (uint16) (*((word32) es_bx_n + 5));
	byte bLoc0C_n = (byte) ax_n;
	word16 dx_n = Mem29[ds:11857:word16] + ax_n;
	struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
	byte Eq_n::* di_n = (word16) ptrArg02;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		byte Eq_n::* di_n;
		di_n = di_n + 1;
		--cx_n;
		di_n = di_n;
		if (es_n->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	word16 bx_n = Mem58[ds:11857:word16] + ((CONVERT(Mem58[ptrArg06 + 0x00:byte], int8, int16) << 0x08) + CONVERT(Mem58[ptrArg06 + 1:byte], uint8, uint16));
	Eq_n dx_n = Mem58[ds:11859:word16];
	fn0800_B0F3(SEQ(Mem92[ds:11859:word16], bx_n - 0x01 + (cx_n + 0x04)), SEQ(Mem87[ds:11859:word16], bx_n - 0x01), dx_n - (bx_n - 0x01));
	byte bLoc0E_n = (byte) cx_n + 0x04;
	byte Eq_n::* di_n = wArg02_n;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (psegArg04_n->*di_n != 0x00)
			break;
	}
	cu16 cx_n = ~cx_n;
	<unknown>* di_n = di_n - cx_n;
	uint32 size_n = (cx_n >> 0x01) *32 0x02;
	memcpy(bx_n - 0x01, di_n, size_n);
	memcpy(bx_n - 0x01 + (word16) size_n, &(psegArg04_n->*((char *) di_n + (word16) size_n)), cond(cx_n >> 0x01) & 0x02);
	Eq_n es_n = dx_n;
	byte Eq_n::* di_n = bx_n - 0x01;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (dx_n->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	byte Eq_n::* di_n = di_n - cx_n;
	bool v37_n = di_n == 0x00;
	while (cx_n != 0x00)
	{
		v37_n = dx_n->*di_n == 0x00;
		++di_n;
		--cx_n;
		if (dx_n->*di_n != 0x00)
			break;
	}
	if (!v37_n)
	{
		di_n = 0x01;
		es_n.u0 = 0x00;
	}
	es_n->*di_n = 0x00;
	Eq_n es_n = dx_n;
	byte Eq_n::* di_n = bx_n - 0x01;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (dx_n->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	struct Eq_n Eq_n::* di_n = di_n - cx_n;
	bool v41_n = di_n == 0x00;
	while (cx_n != 0x00)
	{
		v41_n = (dx_n->*di_n).b0000 == 0x00;
		++di_n;
		--cx_n;
		if ((dx_n->*di_n).b0000 != 0x00)
			break;
	}
	if (!v41_n)
	{
		di_n = 0x01;
		es_n.u0 = 0x00;
	}
	di_n[1] = (struct Eq_n) 0x00;
	Eq_n es_n = dx_n;
	byte Eq_n::* di_n = bx_n - 0x01;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (dx_n->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	struct Eq_n Eq_n::* di_n = di_n - cx_n;
	bool v45_n = di_n == 0x00;
	while (cx_n != 0x00)
	{
		v45_n = (dx_n->*di_n).b0000 == 0x00;
		++di_n;
		--cx_n;
		if ((dx_n->*di_n).b0000 != 0x00)
			break;
	}
	if (!v45_n)
	{
		di_n = 0x01;
		es_n.u0 = 0x00;
	}
	di_n[2] = (struct Eq_n) 0x00;
	Eq_n es_n = dx_n;
	byte Eq_n::* di_n = bx_n - 0x01;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (dx_n->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	struct Eq_n Eq_n::* di_n = di_n - cx_n;
	bool v49_n = di_n == 0x00;
	byte ch_n;
	do
	{
		ch_n = SLICE(cx_n, byte, 8);
		if (cx_n == 0x00)
			break;
		--cx_n;
		v49_n = (dx_n->*di_n).b0000 == 0x00;
		++di_n;
		ch_n = SLICE(cx_n, byte, 8);
	} while ((dx_n->*di_n).b0000 == 0x00);
	if (!v49_n)
	{
		di_n = 0x01;
		es_n.u0 = 0x00;
	}
	di_n[3] = (struct Eq_n) 0x00;
	Eq_n es_bx_n = Mem388[ds:11857:segptr32];
	es_bx_n.u5->t0004.u0 = (int8) (byte) (ax_n + (cx_n + 0x04) >> 0x08);
	((word32) es_bx_n + 5)->u1 = bLoc0C_n + bLoc0E_n;
	fn0800-2688(ds, (uint32) (cx_n + 0x04), 0x00);
	return ch_n;
}

// 0800:2201: void fn0800-2201(Register Eq_n ds, Stack Eq_n ptrArg02)
// Called from:
//      fn0800-18D9
void fn0800-2201(Eq_n ds, Eq_n ptrArg02)
{
	Eq_n wArg02_n = (word16) ptrArg02;
	Eq_n wArg04_n;
	wArg04_n.u3 = SLICE(ptrArg02, word16, 16);
	Eq_n es_bx_n = Mem12[ds:11857:segptr32];
	uint16 dx_n = Mem31[ds:11857:word16] + ((CONVERT(Mem31[ptrArg02 + 0x00:byte], int8, int16) << 0x08) + CONVERT(Mem31[ptrArg02 + 1:byte], uint8, uint16)) - wArg02_n;
	uint16 ax_n = ((uint16) es_bx_n.u5->t0004.u0 << 0x08) + (uint16) (*((word32) es_bx_n + 5));
	word16 ax_n = (word16) (&wArg02_n.u1->b0000 + dx_n);
	fn0800_B0F3(ptrArg02, SEQ(wArg04_n, ax_n), Mem26[ds:11857:word16] + ax_n - ax_n);
	Eq_n es_bx_n = Mem72[ds:11857:segptr32];
	es_bx_n.u5->t0004.u0 = (int8) (byte) (ax_n - dx_n >> 0x08);
	((word32) es_bx_n + 5)->u1 = (byte) (ax_n - dx_n);
	fn0800-2688(ds, -(uint32) dx_n, 0x00);
	Eq_n dx_n = Mem112[ds:17838:word16];
	if (Mem112[ds:0x45B0:word16] != wArg04_n || dx_n != wArg02_n)
	{
		if (Mem112[ds:17838:word16] >u wArg02_n)
			Mem138[ds:0x45AA:word16] = Mem112[ds:0x45AA:word16] - dx_n;
	}
	else
	{
		struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
		byte Eq_n::* di_n = (word16) ptrArg02 + 0x02;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		word16 cx_n = ~cx_n;
		Eq_n di_n = di_n - cx_n;
		bool v38_n = di_n == 0x00;
		while (cx_n != 0x00)
		{
			v38_n = es_n->*di_n.u3 == 0x00;
			di_n.u3 = (word32) di_n + 1;
			--cx_n;
			if (es_n->*di_n.u3 != 0x00)
				break;
		}
		if (!v38_n)
		{
			di_n.u0 = 0x01;
			es_n = 0x00;
		}
		Mem203[ds:0x45AC:word16] = es_n;
		Mem204[ds:0x45AA:word16] = di_n;
	}
}

// 0800:22FE: void fn0800-22FE(Register Eq_n ds, Stack Eq_n ptrArg02)
// Called from:
//      fn0800-18D9
void fn0800-22FE(Eq_n ds, Eq_n ptrArg02)
{
	Eq_n wArg02_n = (word16) ptrArg02;
	struct Eq_n * wArg04_n = SLICE(ptrArg02, word16, 16);
	Eq_n es_bx_n = Mem12[ds:11857:segptr32];
	uint16 ax_n = ((uint16) es_bx_n.u5->t0004.u0 << 0x08) + (uint16) (*((word32) es_bx_n + 5));
	byte bLoc08_n = (byte) ax_n;
	word16 dx_n = Mem26[ds:11857:word16] + ax_n;
	struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
	byte Eq_n::* di_n = (word16) ptrArg02;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (es_n->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	byte Eq_n::* di_n = di_n - cx_n;
	bool v38_n = di_n == &Eq_n::b0000;
	while (cx_n != 0x00)
	{
		v38_n = es_n->*di_n == 0x00;
		++di_n;
		--cx_n;
		if (es_n->*di_n != 0x00)
			break;
	}
	if (!v38_n)
		di_n = &Eq_n::b0001;
	Eq_n di_n = di_n + 4 - wArg02_n;
	ui16 ax_n = wArg02_n + di_n;
	fn0800_B0F3(ptrArg02, ax_n, dx_n - ax_n);
	Eq_n es_bx_n = Mem123[ds:11857:segptr32];
	es_bx_n.u5->t0004.u0 = (int8) (byte) (ax_n - di_n >> 0x08);
	((word32) es_bx_n + 5)->u1 = bLoc08_n - (byte) di_n;
	fn0800-2688(ds, -(uint32) di_n, 0x00);
	Mem182[ds:0x45AC:word16] = wArg04_n;
	Eq_n dx_n;
	dx_n.u3 = wArg02_n + di_n;
	Mem183[ds:0x45AA:word16] = dx_n;
	if ((dx_n | wArg04_n) == 0x00)
	{
		if (Mem183[ds:0x45AA:word16] >u wArg02_n)
			Mem194[ds:0x45AA:word16] = Mem183[ds:0x45AA:word16] - di_n;
	}
	else
	{
		Mem206[ds:0x45AC:word16] = wArg04_n;
		Mem207[ds:0x45AA:word16] = wArg02_n;
	}
}

// 0800:23EC: Register byte fn0800-23EC(Register Eq_n ds, Stack Eq_n ptrArg02, Register out (memptr Eq_n Eq_n) bpOut, Register out word16 siOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-12E2
//      fn0800-18D9
byte fn0800-23EC(Eq_n ds, Eq_n ptrArg02, struct Eq_n & bpOut, word16 & siOut, union Eq_n & dsOut)
{
	struct Eq_n * wArg04 = SLICE(ptrArg02, word16, 16);
	byte Eq_n::* wArg02 = (word16) ptrArg02;
	Eq_n ds_n = fn0800-24FE(ds, ptrArg02);
	struct Eq_n * es_n = wArg04;
	byte Eq_n::* di_n = wArg02;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (wArg04->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	int8 Eq_n::* di_n = di_n - cx_n;
	bool v38_n = di_n == &Eq_n::b0000;
	while (cx_n != 0x00)
	{
		v38_n = wArg04->*di_n == 0x00;
		++di_n;
		--cx_n;
		if (wArg04->*di_n != 0x00)
			break;
	}
	if (!v38_n)
	{
		di_n = &Eq_n::b0001;
		es_n = 0x00;
	}
	int16 ax_n = (int16) (es_n->*di_n);
	struct Eq_n * es_n = wArg04;
	byte Eq_n::* di_n = wArg02;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (wArg04->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	struct Eq_n Eq_n::* di_n = di_n - cx_n;
	bool v42_n = di_n == &Eq_n::b0000;
	while (cx_n != 0x00)
	{
		v42_n = (wArg04->*di_n).b0000 == 0x00;
		++di_n;
		--cx_n;
		if ((wArg04->*di_n).b0000 != 0x00)
			break;
	}
	if (!v42_n)
	{
		di_n = &Eq_n::b0001;
		es_n = 0x00;
	}
	uint16 dx_n = (ax_n << 0x08) + (uint16) di_n[1];
	struct Eq_n * es_n = wArg04;
	byte Eq_n::* di_n = wArg02;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (wArg04->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	struct Eq_n Eq_n::* di_n = di_n - cx_n;
	bool v46_n = di_n == &Eq_n::b0000;
	while (cx_n != 0x00)
	{
		v46_n = (wArg04->*di_n).b0000 == 0x00;
		++di_n;
		--cx_n;
		if ((wArg04->*di_n).b0000 != 0x00)
			break;
	}
	if (!v46_n)
	{
		di_n = &Eq_n::b0001;
		es_n = 0x00;
	}
	int16 ax_n = (int16) di_n[2];
	struct Eq_n * es_n = wArg04;
	byte Eq_n::* di_n = wArg02;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (wArg04->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	struct Eq_n Eq_n::* di_n = di_n - cx_n;
	bool v50_n = di_n == &Eq_n::b0000;
	while (cx_n != 0x00)
	{
		v50_n = (wArg04->*di_n).b0000 == 0x00;
		++di_n;
		--cx_n;
		if ((wArg04->*di_n).b0000 != 0x00)
			break;
	}
	if (!v50_n)
	{
		di_n = &Eq_n::b0001;
		es_n = 0x00;
	}
	ui32 ax_dx_n = SEQ(dx_n, 0x00) + CONVERT((ax_n << 0x08) + CONVERT(Mem247[es_n:di_n + 0x03:byte], uint8, uint16), uint16, uint32) - Mem331[ds_n:0x45A6:ui32];
	struct Eq_n Eq_n::* bp_n;
	word16 si_n;
	Eq_n ds_n;
	fn0800-3C99(ds_n, Mem362[ds_n:10703:word32], SLICE(ax_dx_n, word16, 0), SLICE(ax_dx_n, word16, 16), out bp_n, out si_n, out ds_n);
	Eq_n sp_n;
	sp_n.u0 = <invalid>;
	selector ss;
	(ss->*sp_n.u5).t000A.u2 = (ss->*bp_n).wFFFFFFFE;
	(ss->*sp_n.u5).t0008.u2 = (ss->*bp_n).tFFFFFFFC.u1;
	ui32 ax_dx_n = -(ss->*bp_n).dwFFFFFFF8;
	(ss->*sp_n.u5).t0006.u2 = SLICE(ax_dx_n, word16, 16);
	(ss->*sp_n.u5).t0004.u1.u2 = (uint16) (word16) ax_dx_n;
	fn0800-2688(ds_n, (ss->*sp_n.u5).t0004.u1.u3, (ss->*sp_n.u5).t0008.u3);
	bpOut = (ss->*bp_n).ptr0000;
	siOut = si_n;
	dsOut = ds_n;
	return 0x00;
}

// 0800:24FE: Register Eq_n fn0800-24FE(Register Eq_n ds, Stack Eq_n ptrArg02)
// Called from:
//      fn0800-19EE
//      fn0800-23EC
Eq_n fn0800-24FE(Eq_n ds, Eq_n ptrArg02)
{
	Eq_n ds_n;
	word16 dx_n;
	byte cl_n;
	Eq_n ds_n;
	struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
	byte Eq_n::* di_n = (word16) ptrArg02;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (es_n->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	int8 Eq_n::* di_n = di_n - cx_n;
	bool v42_n = di_n == &Eq_n::b0000;
	while (cx_n != 0x00)
	{
		v42_n = es_n->*di_n == 0x00;
		++di_n;
		--cx_n;
		if (es_n->*di_n != 0x00)
			break;
	}
	if (!v42_n)
	{
		di_n = &Eq_n::b0001;
		es_n = 0x00;
	}
	int16 ax_n = (int16) (es_n->*di_n);
	struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
	byte Eq_n::* di_n = (word16) ptrArg02;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (es_n->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	struct Eq_n Eq_n::* di_n = di_n - cx_n;
	bool v46_n = di_n == &Eq_n::t0000;
	while (cx_n != 0x00)
	{
		v46_n = (es_n->*di_n).b0000 == 0x00;
		++di_n;
		--cx_n;
		if ((es_n->*di_n).b0000 != 0x00)
			break;
	}
	if (!v46_n)
	{
		di_n = &Eq_n::t0001;
		es_n = 0x00;
	}
	uint16 dx_n = (ax_n << 0x08) + (uint16) di_n[1];
	struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
	byte Eq_n::* di_n = (word16) ptrArg02;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (es_n->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	struct Eq_n Eq_n::* di_n = di_n - cx_n;
	bool v50_n = di_n == &Eq_n::t0000;
	while (cx_n != 0x00)
	{
		v50_n = (es_n->*di_n).b0000 == 0x00;
		++di_n;
		--cx_n;
		if ((es_n->*di_n).b0000 != 0x00)
			break;
	}
	if (!v50_n)
	{
		di_n = &Eq_n::t0001;
		es_n = 0x00;
	}
	int16 ax_n = (int16) di_n[2];
	struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
	byte Eq_n::* di_n = (word16) ptrArg02;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (es_n->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	struct Eq_n Eq_n::* di_n = di_n - cx_n;
	bool v54_n = di_n == &Eq_n::t0000;
	while (cx_n != 0x00)
	{
		v54_n = (es_n->*di_n).b0000 == 0x00;
		++di_n;
		--cx_n;
		if ((es_n->*di_n).b0000 != 0x00)
			break;
	}
	if (!v54_n)
	{
		di_n = &Eq_n::t0001;
		es_n = 0x00;
	}
	word16 cx_n;
	fn0800_ACB3(ds, Mem339[ds:10703:word32], SEQ(dx_n, 0x00) + CONVERT((ax_n << 0x08) + CONVERT(Mem224[es_n:di_n + 0x03:byte], uint8, uint16), uint16, uint32) - Mem224[ds:0x45A6:ui32], 0x00, out cx_n);
	Eq_n dx_ax_n = fn0800-3E5D(ds, Mem345[ds:10703:word32], out ds_n);
	cui16 ax_n = (word16) dx_ax_n;
	Eq_n ax_n = fn0800-8C8A(dx_ax_n, 0x08, out cl_n, out dx_n);
	if (dx_n != 0x52 || ax_n != 0x4E43)
	{
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		word16 si_n;
		word16 di_n;
		fn0800-0D24(ds_n, 0x0C, SEQ(ds_n, 0x4348), out cx_n, out dx_n, out bx_n, out si_n, out di_n, out ds_n);
	}
	Eq_n ds_n;
	if ((ax_n & 0xFF) != 0x00)
	{
		Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem422[ds_n:10703:word32], out ds_n);
		Mem480[ds_n:0x2A09:word16] = SLICE(dx_ax_n, word16, 16);
		Mem481[ds_n:0x2A07:word16] = SLICE(dx_ax_n, word16, 0);
		Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem481[ds_n:10703:word32], out ds_n);
		Mem500[ds_n:0x2A05:word16] = SLICE(dx_ax_n, word16, 16);
		Mem501[ds_n:0x2A03:word16] = SLICE(dx_ax_n, word16, 0);
	}
	else
	{
		Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem422[ds_n:10703:word32], out ds_n);
		Eq_n dx_n;
		dx_n.u3 = SLICE(dx_ax_n, word16, 16);
		Mem450[ds_n:0x2A05:word16] = dx_n;
		Eq_n ax_n = (word16) dx_ax_n;
		Mem451[ds_n:0x2A03:word16] = ax_n;
		Mem452[ds_n:0x2A09:word16] = dx_n;
		Mem453[ds_n:0x2A07:word16] = ax_n;
	}
	return ds_n;
}

// 0800:2688: Register byte fn0800-2688(Register Eq_n ds, Stack Eq_n dwArg02, Stack Eq_n dwArg06)
// Called from:
//      fn0800-1F5C
//      fn0800-2085
//      fn0800-2201
//      fn0800-22FE
//      fn0800-23EC
byte fn0800-2688(Eq_n ds, Eq_n dwArg02, Eq_n dwArg06)
{
	word16 wArg02 = (word16) dwArg02;
	Eq_n es_bx_n = Mem7[ds:11857:segptr32];
	byte cl_n = 0x08;
	Eq_n dx_n = Mem7[ds:11859:word16];
	word16 bx_n = (word16) es_bx_n + (((uint16) ((es_bx_n.u5)->t0004).u0 << 0x08) + (uint16) (*((word32) es_bx_n + 5)));
	struct Eq_n * ptrLoc06_n = SEQ(Mem26[ds:11859:word16], Mem26[ds:11857:word16] + 0x08);
	while (true)
	{
		word16 wLoc06_n = (word16) ptrLoc06_n;
		Eq_n wLoc04_n;
		wLoc04_n.u3 = SLICE(ptrLoc06_n, word16, 16);
		if (wLoc04_n == dx_n && wLoc06_n == bx_n)
			break;
		struct Eq_n * ptrLoc06_n = SEQ(wLoc04_n, wLoc06_n + 0x02);
		struct Eq_n * ptrLoc06_n;
		do
		{
			word16 wLoc04_n;
			word16 wLoc06_n;
			ptrLoc06_n = SEQ(wLoc04_n, wLoc06_n + 0x01);
			wLoc06_n = (word16) ptrLoc06_n;
			wLoc04_n = SLICE(ptrLoc06_n, word16, 16);
			ptrLoc06_n = ptrLoc06_n;
		} while (ptrLoc06_n->b0000 != 0x00);
		word16 wLoc06_n;
		word16 wLoc04_n;
		while (true)
		{
			byte bArg02_n = (byte) wArg02;
			wLoc06_n = (word16) ptrLoc06_n;
			wLoc04_n = SLICE(ptrLoc06_n, word16, 16);
			if (ptrLoc06_n->b0000 == 0x00)
				break;
			word16 wLoc06_n;
			struct Eq_n * ptrLoc06_n;
			word16 wLoc04_n;
			do
			{
				wLoc06_n = (word16) ptrLoc06_n;
				wLoc04_n = SLICE(ptrLoc06_n, word16, 16);
				ptrLoc06_n = SEQ(wLoc04_n, wLoc06_n + 0x01);
				ptrLoc06_n = ptrLoc06_n;
			} while (ptrLoc06_n->b0000 != 0x00);
			Eq_n ax_dx_n = SEQ(((int16) ptrLoc06_n->b0000 << 0x08) + (uint16) ptrLoc06_n->b0001, 0x00) + (uint32) (((int16) ptrLoc06_n->b0002 << 0x08) + (uint16) ptrLoc06_n->b0003);
			byte bLoc12_n = (byte) ax_dx_n;
			if (ax_dx_n >= dwArg06)
			{
				byte cl_n;
				word16 dx_n;
				ptrLoc06_n->b0000 = (byte) fn0800-8C8A((int32) SLICE(ax_dx_n + dwArg02, word16, 16), 0x08, out cl_n, out dx_n);
				ptrLoc06_n->b0001 = SLICE(ax_dx_n + dwArg02, byte, 16);
				byte cl_n;
				word16 dx_n;
				ptrLoc06_n->b0002 = (byte) fn0800-8C8A(ax_dx_n + dwArg02, 0x08, out cl_n, out dx_n);
				ptrLoc06_n->b0003 = bLoc12_n + bArg02_n;
			}
			ptrLoc06_n = SEQ(wLoc04_n, wLoc06_n + 0x05);
		}
		word16 dx_n;
		Mem116[ptrLoc06_n + 0x00:byte] = SLICE(fn0800-8C8A(CONVERT(wLoc06_n + 0x01 - Mem93[ds:11857:word16], word16, uint32), 0x08, out cl_n, out dx_n), byte, 0);
		Mem125[ptrLoc06_n + 1:byte] = SLICE(wLoc06_n, byte, 0) + 0x01 - Mem116[ds:11857:byte];
		ptrLoc06_n = SEQ(wLoc04_n, wLoc06_n + 0x01);
	}
	if (dwArg06 == 0x00)
		Mem56[ds:0x45A6:ui32] = Mem52[ds:0x45A6:ui32] + dwArg02;
	return cl_n;
}

// 0800:283D: Register word16 fn0800-283D(Register Eq_n ds, Stack Eq_n ptrArg02, Register out Eq_n dxOut)
// Called from:
//      fn0800-12E2
word16 fn0800-283D(Eq_n ds, Eq_n ptrArg02, union Eq_n & dxOut)
{
	struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
	byte Eq_n::* di_n = (word16) ptrArg02;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (es_n->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	Eq_n di_n = di_n - cx_n;
	bool v30_n = di_n == 0x00;
	while (cx_n != 0x00)
	{
		v30_n = es_n->*di_n == 0x3A;
		di_n = (word16) di_n + 1;
		--cx_n;
		if (es_n->*di_n != 0x3A)
			break;
	}
	if (!v30_n)
	{
		di_n.u0 = 0x01;
		es_n = 0x00;
	}
	if ((di_n - 0x01 | es_n) != 0x00)
	{
		struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
		byte Eq_n::* di_n = (word16) ptrArg02;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		word16 cx_n = ~cx_n;
		byte Eq_n::* di_n = di_n - cx_n;
		bool v34_n = di_n == &Eq_n::b0000;
		while (cx_n != 0x00)
		{
			v34_n = es_n->*di_n == 0x3A;
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x3A)
				break;
		}
		if (!v34_n)
		{
			di_n = &Eq_n::b0001;
			es_n = 0x00;
		}
		ptrArg02.u3 = &(es_n->*di_n);
	}
	Eq_n es_bx_n = Mem149[ds:11857:segptr32];
	Eq_n dx_n = Mem149[ds:11859:word16];
	word16 bx_n = (word16) es_bx_n + (((uint16) ((es_bx_n.u5)->t0004).u0 << 0x08) + (uint16) (*((word32) es_bx_n + 5)));
	struct Eq_n * ptrLoc0A_n = SEQ(Mem167[ds:11859:word16], Mem167[ds:11857:word16] + 0x08);
	while (true)
	{
		word16 wLoc0A_n = (word16) ptrLoc0A_n;
		Eq_n wLoc08_n;
		wLoc08_n.u3 = SLICE(ptrLoc0A_n, word16, 16);
		if (wLoc08_n == dx_n && wLoc0A_n == bx_n)
			break;
		struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
		byte Eq_n::* di_n = (word16) ptrArg02;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		word16 cx_n = ~cx_n;
		cui16 ax_n = 0x00;
		Eq_n cmpResult_n = memcmp(&ptrLoc0A_n->b0001 + 1, di_n - cx_n, (uint32) cx_n);
		if (cmpResult_n != 0x00)
		{
			cup16 ax_n = 0x00 - (word16) (cmpResult_n < 0x00);
			ax_n = ax_n - ~0x00 - (word16) (ax_n < 0x00);
		}
		if (ax_n == 0x00)
		{
			dxOut = wLoc08_n;
			return wLoc0A_n;
		}
		ptrLoc0A_n = SEQ(Mem193[ds:11859:word16], Mem193[ds:11857:word16] + ((CONVERT(Mem193[ptrLoc0A_n + 0x00:byte], int8, int16) << 0x08) + CONVERT(Mem193[ptrLoc0A_n + 1:byte], uint8, uint16)));
	}
	dxOut.u0 = 0x00;
	return 0x00;
}

// 0800:2931: Register word16 fn0800-2931(Stack Eq_n ptrArg02, Stack Eq_n ptrArg06, Register out word16 dxOut)
// Called from:
//      fn0800-12E2
word16 fn0800-2931(Eq_n ptrArg02, Eq_n ptrArg06, word16 & dxOut)
{
	struct Eq_n * es_n = SLICE(ptrArg06, selector, 16);
	byte Eq_n::* di_n = (word16) ptrArg06 + 0x02;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (es_n->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	byte Eq_n::* di_n = di_n - cx_n;
	bool v27_n = di_n == &Eq_n::b0000;
	while (cx_n != 0x00)
	{
		v27_n = es_n->*di_n == 0x00;
		++di_n;
		--cx_n;
		if (es_n->*di_n != 0x00)
			break;
	}
	if (!v27_n)
	{
		di_n = &Eq_n::b0001;
		es_n = 0x00;
	}
	byte * ptrArg06_n = &(es_n->*di_n);
	while (*ptrArg06_n != 0x00)
	{
		struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
		byte Eq_n::* di_n = (word16) ptrArg02;
		word16 cx_n = ~0x00;
		word16 wArg08_n = SLICE(ptrArg06_n, word16, 16);
		word16 wArg06_n = (word16) ptrArg06_n;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		word16 cx_n = ~cx_n;
		cui16 ax_n = 0x00;
		Eq_n cmpResult_n = memcmp(ptrArg06_n, di_n - cx_n, (uint32) cx_n);
		if (cmpResult_n != 0x00)
		{
			cup16 ax_n = 0x00 - (word16) (cmpResult_n < 0x00);
			ax_n = ax_n - ~0x00 - (word16) (ax_n < 0x00);
		}
		if (ax_n == 0x00)
		{
			dxOut = wArg08_n;
			return wArg06_n;
		}
		struct Eq_n * es_n = SLICE(ptrArg06_n, selector, 16);
		byte Eq_n::* di_n = (word16) ptrArg06_n;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		word16 cx_n = ~cx_n;
		byte Eq_n::* di_n = di_n - cx_n;
		bool v31_n = di_n == &Eq_n::b0000;
		while (cx_n != 0x00)
		{
			v31_n = es_n->*di_n == 0x00;
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		if (!v31_n)
		{
			di_n = &Eq_n::b0001;
			es_n = 0x00;
		}
		ptrArg06_n = &(es_n->*(di_n + 4));
	}
	dxOut = 0x00;
	return 0x00;
}

// 0800:29C5: Register word16 fn0800-29C5(Register Eq_n cx, Register Eq_n dx, Register Eq_n si, Register Eq_n ds, Stack Eq_n ptrArg02, Stack Eq_n ptrArg06, Stack Eq_n ptrArg0A, Register out Eq_n dsOut)
// Called from:
//      fn0800-18D9
//      fn0800-19EE
//      fn0800-29C5
word16 fn0800-29C5(Eq_n cx, Eq_n dx, Eq_n si, Eq_n ds, Eq_n ptrArg02, Eq_n ptrArg06, Eq_n ptrArg0A, union Eq_n & dsOut)
{
	selector ds_n;
	struct Eq_n * wArg0C = SLICE(ptrArg0A, word16, 16);
	Eq_n wArg0A = (word16) ptrArg0A;
	Eq_n wArg06 = (word16) ptrArg06;
	Eq_n wArg02 = (word16) ptrArg02;
	if ((Mem15[ds:17838:word16] | Mem15[ds:0x45B0:word16]) == 0x00 && (Mem15[ds:0x45AA:word16] | Mem15[ds:0x45AC:word16]) == 0x00)
	{
		word16 cx_n;
		word16 dx_n;
		if (fn0800-2DE2(cx, dx, si, ds, SEQ(ds, 0x4541), out cx_n, out dx_n, out si, out ds) == 0x00)
		{
			dsOut = ds;
			return 0x00;
		}
		Eq_n dx_n = Mem33[ds:11857:word16];
		Mem60[ds:0x45B0:word16] = Mem33[ds:11859:word16];
		Mem61[ds:17838:word16] = dx_n + 0x08;
	}
	mp16 fp;
	Eq_n ss;
	word16 bx_n;
	fn0800-3509(fp - 0x006C, ss, SEQ(ds, 0x4541), out bx_n);
	word16 dx_n;
	fn0800-35A3(fp - 122, ss, SEQ(ds, 0x4541), out dx_n);
	Eq_n es_bx_n = Mem97[ds:11857:segptr32];
	word16 dx_n = Mem97[ds:11859:word16];
	Eq_n bx_n = (word16) es_bx_n + (((uint16) ((es_bx_n.u5)->t0004).u0 << 0x08) + (uint16) (*((word32) es_bx_n + 5)));
	Eq_n cx_n;
	cx_n.u0 = 0x08;
	while (true)
	{
		Eq_n dx_n = Mem127[ds:17838:word16];
		if (Mem127[ds:0x45B0:word16] == dx_n && dx_n == bx_n)
			break;
		if ((Mem127[ds:0x45AA:word16] | Mem127[ds:0x45AC:word16]) != 0x00)
		{
			while (Mem192[Mem192[ds:0x45AA:segptr32] + 0x00:byte] != 0x00)
			{
				if (fn0800-4357(Mem222[ds:0x45AA:word32], SEQ(ss, fp - 122)) != 0x00)
				{
					Eq_n dx_n = Mem228[ds:17838:word16];
					Mem248[ptrArg02 + 2:word16] = Mem228[ds:0x45B0:word16];
					ptrArg02.u1->t0000.u0 = (word16) dx_n;
					Eq_n dx_n = Mem249[ds:0x45AA:word16];
					Mem255[ptrArg06 + 2:word16] = Mem249[ds:0x45AC:word16];
					ptrArg06.u5->t0000.u1.u2 = (uint16) dx_n;
					Eq_n es_di_n = Mem256[ds:17838:segptr32];
					struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
					byte Eq_n::* di_n = (word16) es_di_n + 0x02;
					word16 cx_n = ~0x00;
					while (cx_n != 0x00)
					{
						++di_n;
						--cx_n;
						if (es_n->*di_n != 0x00)
							break;
					}
					cu16 cx_n = ~cx_n;
					<unknown>* di_n = di_n - cx_n;
					uint32 size_n = (cx_n >> 0x01) *32 0x02;
					memcpy(ptrArg0A, di_n, size_n);
					memcpy(ptrArg0A + (word16) size_n, &(es_n->*((char *) di_n + (word16) size_n)), cond(cx_n >> 0x01) & 0x02);
					struct Eq_n * es_n = Mem329[ds:0x45AC:selector];
					Eq_n di_n = Mem333[ds:0x45AA:word16];
					word16 cx_n = ~0x00;
					while (cx_n != 0x00)
					{
						di_n.u3 = (word32) di_n + 1;
						--cx_n;
						if (es_n->*di_n.u3 != 0x00)
							break;
					}
					word16 cx_n = ~cx_n;
					word16 di_n = di_n - cx_n;
					Eq_n di_n = wArg0A;
					word16 cx_n = ~0x00;
					while (cx_n != 0x00)
					{
						di_n.u3 = &di_n.u5->b0001;
						--cx_n;
						if (wArg0C->*di_n.u3 != 0x00)
							break;
					}
					memcpy(di_n - 0x01, di_n, (uint32) cx_n);
					Eq_n es_di_n = Mem370[ds:0x45AA:segptr32];
					struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
					byte Eq_n::* di_n = (word16) es_di_n;
					word16 cx_n = ~0x00;
					while (cx_n != 0x00)
					{
						++di_n;
						--cx_n;
						if (es_n->*di_n != 0x00)
							break;
					}
					word16 cx_n = ~cx_n;
					byte Eq_n::* di_n = di_n - cx_n;
					bool v47_n = di_n == &Eq_n::b0000;
					while (cx_n != 0x00)
					{
						v47_n = es_n->*di_n == 0x00;
						++di_n;
						--cx_n;
						if (es_n->*di_n != 0x00)
							break;
					}
					if (!v47_n)
					{
						di_n = &Eq_n::b0001;
						es_n = 0x00;
					}
					Mem453[ds:0x45AC:word16] = es_n;
					Mem454[ds:0x45AA:word16] = di_n + 0x04;
					dsOut = ds;
					return 0x01;
				}
				Eq_n es_di_n = Mem228[ds:0x45AA:segptr32];
				struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
				byte Eq_n::* di_n = (word16) es_di_n;
				word16 cx_n = ~0x00;
				while (cx_n != 0x00)
				{
					++di_n;
					--cx_n;
					if (es_n->*di_n != 0x00)
						break;
				}
				word16 cx_n = ~cx_n;
				byte Eq_n::* di_n = di_n - cx_n;
				bool v51_n = di_n == &Eq_n::b0000;
				while (cx_n != 0x00)
				{
					v51_n = es_n->*di_n == 0x00;
					++di_n;
					--cx_n;
					if (es_n->*di_n != 0x00)
						break;
				}
				if (!v51_n)
				{
					di_n = &Eq_n::b0001;
					es_n = 0x00;
				}
				Mem533[ds:0x45AC:word16] = es_n;
				Mem534[ds:0x45AA:word16] = di_n + 0x04;
			}
			ptr32 es_bx_n = Mem192[ds:17838:segptr32];
			Eq_n bx_n = Mem192[ds:11857:word16] + ((CONVERT(Mem192[es_bx_n + 0x00:byte], int8, int16) << 0x08) + CONVERT(Mem192[es_bx_n + 1:byte], uint8, uint16));
			Mem213[ds:0x45B0:word16] = Mem192[ds:11859:word16];
			Mem214[ds:17838:word16] = bx_n;
		}
		while (true)
		{
			Eq_n dx_n = Mem536[ds:17838:word16];
			if (Mem536[ds:0x45B0:word16] == dx_n && dx_n == bx_n)
				break;
			if (Mem536[ds:10779:word16] != 0x00)
			{
				byte Eq_n::* di_n = fp - 0x006C;
				word16 cx_n = ~0x00;
				while (cx_n != 0x00)
				{
					byte Eq_n::* di_n;
					di_n = di_n + 1;
					--cx_n;
					di_n = di_n;
					if (ss->*di_n != 0x00)
						break;
				}
				if (fn0800_BFE6(SEQ(Mem587[ds:0x45B0:word16], Mem587[ds:17838:word16] + 0x02), SEQ(ss, fp - 0x006C), -cx_n) == 0x00)
					break;
			}
			if (Mem615[ds:10779:word16] == 0x00)
			{
				Eq_n si_n = Mem615[ds:17838:word16];
				Eq_n ds_n = Mem623[ds:0x45B0:selector];
				byte Eq_n::* di_n = fp - 0x006C;
				word16 cx_n = ~0x00;
				while (cx_n != 0x00)
				{
					++di_n;
					--cx_n;
					if (ss->*di_n != 0x00)
						break;
				}
				ui16 cx_n = ~cx_n;
				<unknown>* di_n = di_n - cx_n;
				Eq_n cmpResult_n = memcmp((word16) si_n.u0 + 2, di_n, (uint32) cx_n);
				cui16 ax_n = 0x00;
				si = (word16) si_n.u0 + 2 + __find_first_difference__((word16) si_n.u0 + 2, di_n);
				if (cmpResult_n != 0x00)
				{
					cup16 ax_n = 0x00 - (word16) (cmpResult_n < 0x00);
					ax_n = ax_n - ~0x00 - (word16) (ax_n < 0x00);
				}
				if (ax_n == 0x00)
					break;
			}
			ptr32 es_bx_n = Mem747[ds:17838:segptr32];
			Eq_n bx_n = Mem747[ds:11857:word16] + ((CONVERT(Mem747[es_bx_n + 0x00:byte], int8, int16) << 0x08) + CONVERT(Mem747[es_bx_n + 1:byte], uint8, uint16));
			Mem763[ds:0x45B0:word16] = Mem747[ds:11859:word16];
			Mem764[ds:17838:word16] = bx_n;
		}
		Eq_n es_di_n = Mem689[ds:17838:segptr32];
		struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
		byte Eq_n::* di_n = (word16) es_di_n + 0x02;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		cx_n = ~cx_n;
		Eq_n di_n = di_n - cx_n;
		bool v55_n = di_n == 0x00;
		while (cx_n != 0x00)
		{
			v55_n = es_n->*di_n.u3 == 0x00;
			di_n.u3 = (word32) di_n + 1;
			--cx_n;
			if (es_n->*di_n.u3 != 0x00)
				break;
		}
		if (!v55_n)
		{
			di_n.u0 = 0x01;
			es_n = 0x00;
		}
		Mem744[ds:0x45AC:word16] = es_n;
		Mem745[ds:0x45AA:word16] = di_n;
	}
	Mem141[ds:0x45AC:word16] = 0x00;
	Mem142[ds:0x45AA:word16] = 0x00;
	Mem143[ds:0x45B0:word16] = 0x00;
	Mem144[ds:17838:word16] = 0x00;
	word16 ax_n = fn0800-29C5(cx_n, 0x00, si, ds, wArg02, wArg06, wArg0A, out ds_n);
	dsOut = ds;
	return ax_n;
}

// 0800:2C9A: Register uint16 fn0800-2C9A(Register Eq_n ds, Register out uint16 dxOut, Register out word16 bxOut)
// Called from:
//      main
uint16 fn0800-2C9A(Eq_n ds, uint16 & dxOut, word16 & bxOut)
{
	uint16 cx_n;
	word16 Eq_n::* si_n = 0x2A29;
	uint16 dx_n;
	word16 bx_n;
	for (cx_n = 0x00; cx_n < 0x0100; ++cx_n)
	{
		dx_n = cx_n;
		for (bx_n = 0x08; bx_n != 0x00; --bx_n)
		{
			uint16 ax_n;
			if ((dx_n & 0x01) != 0x00)
				ax_n = dx_n >> 0x01 ^ 0xA001;
			else
				ax_n = dx_n >> 0x01;
			dx_n = ax_n;
		}
		ds->*si_n = dx_n;
		++si_n;
	}
	dxOut = dx_n;
	bxOut = bx_n;
	return cx_n;
}

// 0800:2CCF: Register Eq_n fn0800-2CCF(Register Eq_n ds, Stack Eq_n ptrArg02, Stack Eq_n wArg06, Stack Eq_n wArg08, Register out uint8 clOut, Register out uint16 dxOut)
// Called from:
//      fn0800-12E2
//      fn0800-1CF6
//      fn0800-1E5E
//      fn0800-2D0A
Eq_n fn0800-2CCF(Eq_n ds, Eq_n ptrArg02, Eq_n wArg06, Eq_n wArg08, uint8 & clOut, uint16 & dxOut)
{
	Eq_n si_n = wArg06;
	Eq_n ax_n = wArg08;
	uint8 cl;
	uint16 dx;
	while (true)
	{
		byte bArg08_n = (byte) ax_n;
		word16 wArg02_n = (word16) ptrArg02;
		word16 wArg04_n = SLICE(ptrArg02, word16, 16);
		--si_n;
		if (si_n == 0x00)
			break;
		cl = 0x08;
		dx = ax_n >> 0x08;
		ax_n = (*((word32) ds + 0x00002A29))[(uint16) (bArg08_n ^ *ptrArg02.u3) & 0xFF] ^ ax_n >> 0x08;
		ptrArg02 = SEQ(wArg04_n, wArg02_n + 0x01);
	}
	clOut = cl;
	dxOut = dx;
	return ax_n;
}

// 0800:2D0A: Register cu16 fn0800-2D0A(Register Eq_n ds, Register out word16 bpOut, Register out (ptr16 Eq_n) dsOut)
// Called from:
//      fn0800-5374
cu16 fn0800-2D0A(Eq_n ds, word16 & bpOut, struct Eq_n & dsOut)
{
	Eq_n ds_n;
	word16 si_n;
	struct Eq_n Eq_n::* bp_n;
	Eq_n dx_n;
	Eq_n ax_n = fn0800-4311(ds, 0xFFF0, out dx_n, out bp_n, out si_n, out ds_n);
	selector ss;
	(ss->*bp_n).tFFFFFFFE.u2 = (uint16) dx_n;
	(ss->*bp_n).tFFFFFFFC.u2 = (uint16) ax_n;
	Eq_n sp_n;
	sp_n.u0 = <invalid>;
	(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).t0006.u2;
	(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).t0004.u2;
	Eq_n dx_ax_n = fn0800_AD2F(ds_n, (ss->*sp_n.u5).t0000.u1.u3);
	(ss->*bp_n).tFFFFFFF6.u2 = SLICE(dx_ax_n, word16, 16);
	(ss->*bp_n).tFFFFFFF4.u2 = (uint16) (word16) dx_ax_n;
	cu16 si_n = 0x00;
	while (((ss->*bp_n).t0008.u2 | ((ss->*bp_n).t000A).u2) != 0x00)
	{
		Eq_n dx_n;
		Eq_n ax_n;
		if ((ss->*bp_n).t0008.u3 > 0xFFF0)
		{
			dx_n.u0 = 0x00;
			ax_n.u0 = ~0x0F;
		}
		else
		{
			dx_n.u2 = (ss->*bp_n).t000A.u2;
			ax_n.u2 = (ss->*bp_n).t0008.u2;
		}
		(ss->*bp_n).tFFFFFFFA.u2 = (uint16) dx_n;
		(ss->*bp_n).tFFFFFFF8.u2 = (uint16) ax_n;
		(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).t0006.u2;
		(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).t0004.u2;
		(ss->*((word32) sp_n - 2)).u2 = (ss->*bp_n).tFFFFFFFA.u2;
		ss->*((word32) sp_n - 4) = ax_n;
		(ss->*((word32) sp_n - 6)).u2 = (ss->*bp_n).tFFFFFFFE.u2;
		(ss->*((word32) sp_n - 8)).u2 = (ss->*bp_n).tFFFFFFFC.u2;
		Eq_n si_n;
		word16 di_n;
		fn0800-4110(ds_n, ss->*((word32) sp_n - 8), ss->*((word32) sp_n - 4), ss->*((word32) sp_n - 2), ss->*sp_n.u4, out si_n, out di_n, out ds_n);
		(ss->*sp_n.u5).t0002.u1.u2 = (uint16) si_n;
		(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).tFFFFFFF8.u2;
		(ss->*((word32) sp_n - 2)).u2 = (ss->*bp_n).tFFFFFFFE.u2;
		(ss->*((word32) sp_n - 4)).u2 = (ss->*bp_n).tFFFFFFFC.u2;
		byte cl_n;
		word16 dx_n;
		si_n = fn0800-2CCF(ds_n, ss->*((word32) sp_n - 4), (ss->*sp_n.u5).t0000.u1.u2, (ss->*sp_n.u5).t0002.u1.u2, out cl_n, out dx_n);
		(ss->*bp_n).t0008.u3 = (char *) ((ss->*bp_n).t0008.u3 - ((ss->*bp_n).tFFFFFFF8).u3);
	}
	(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x00;
	(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).tFFFFFFF6.u2;
	(ss->*((word32) sp_n - 2)).u2 = (ss->*bp_n).tFFFFFFF4.u2;
	(ss->*((word32) sp_n - 4)).u2 = (ss->*bp_n).t0006.u2;
	(ss->*((word32) sp_n - 6)).u2 = (ss->*bp_n).t0004.u2;
	word16 cx_n;
	fn0800_ACB3(ds_n, ss->*((word32) sp_n - 6), ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0002.u1.u2, out cx_n);
	(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFFE.u2;
	(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).tFFFFFFFC.u2;
	word16 cx_n;
	word16 dx_n;
	word16 bx_n;
	struct Eq_n * ds_n;
	fn0800-4346(ds_n, (ss->*sp_n.u5).t0002.u1.u2, out cx_n, out dx_n, out bx_n, out ds_n);
	bpOut = (ss->*bp_n).w0000;
	dsOut = ds_n;
	return si_n;
}

// 0800:2DBF: void fn0800-2DBF(Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n wArg04)
// Called from:
//      main
//      fn0800-12E2
//      fn0800-18D9
//      fn0800-19EE
void fn0800-2DBF(Eq_n ds, Eq_n wArg02, Eq_n wArg04)
{
	Mem10[ds:0x4656:word16] = ~0x00;
	Mem11[ds:0x4654:word16] = 0x00;
	Mem13[ds:18002:word16] = Mem11[ds:0x2A27:word16];
	Mem15[ds:18000:word16] = wArg02;
	Mem17[ds:0x464E:word16] = wArg04;
}

// 0800:2DE2: Register word16 fn0800-2DE2(Register Eq_n cx, Register Eq_n dx, Register Eq_n si, Register Eq_n ds, Stack Eq_n ptrArg02, Register out Eq_n cxOut, Register out Eq_n dxOut, Register out Eq_n siOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-0DE8
//      fn0800-112D
//      fn0800-12E2
//      fn0800-29C5
//      fn0800-2DE2
word16 fn0800-2DE2(Eq_n cx, Eq_n dx, Eq_n si, Eq_n ds, Eq_n ptrArg02, union Eq_n & cxOut, union Eq_n & dxOut, union Eq_n & siOut, union Eq_n & dsOut)
{
	selector ds_n;
	word16 si_n;
	Eq_n dx_n;
	Eq_n cx_n;
	selector ds_n;
	word16 si_n;
	Eq_n dx_n;
	Eq_n cx_n;
	selector ds_n;
	word16 si_n;
	Eq_n dx_n;
	Eq_n cx_n;
	Eq_n ds_n;
	Eq_n si_n;
	cui16 dx_n;
	word16 cx_n;
	selector ds_n;
	word16 si_n;
	Eq_n dx_n;
	Eq_n cx_n;
	selector ds_n;
	word16 si_n;
	Eq_n dx_n;
	Eq_n cx_n;
	Eq_n wArg04_n;
	wArg04_n.u3 = SLICE(ptrArg02, word16, 16);
	Eq_n wArg02_n = (word16) ptrArg02;
	<unknown> Eq_n::* fp;
	if (Mem15[ds:0x4654:word16] == 0x00 && (Mem15[ds:18002:word16] == Mem15[ds:0x4656:word16] && Mem15[ds:0x464E:word16] != 0x00))
		si = fn0800-3479(ds, fp - 18, 0x00, out cx, out dx);
	if (Mem50[ds:0x4654:word16] != 0x00)
	{
		Mem53[ds:0x4617:word16] = 0x00;
		word16 dx_n;
		if ((fn0800_A77D(ds, SEQ(ds, 0x45B2), 101, Mem53[ds:17947:word32], out dx_n) | dx_n) == 0x00)
		{
			Eq_n ds_n;
			fn0800_A614(ds, Mem69[ds:17947:word32], out ds_n);
			Mem463[ds_n:0x4654:word16] = 0x00;
			Mem464[ds_n:17949:word16] = 0x00;
			Mem465[ds_n:17947:word16] = 0x00;
			Mem467[ds_n:18002:word16] = Mem465[ds_n:18002:word16] + 0x01;
			word16 ax_n = fn0800-2DE2(cx_n, dx_n, si, ds_n, wArg02_n, out cx_n, out dx_n, out si_n, out ds_n);
			cxOut = cx_n;
			dxOut = dx_n;
			siOut.u0 = <invalid>;
			dsOut = ds_n;
			return ax_n;
		}
		Eq_n es_n = ds;
		byte Eq_n::* di_n = 0x45B2;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (ds->*di_n != 0x00)
				break;
		}
		word16 cx_n = ~cx_n;
		Eq_n di_n = di_n - cx_n;
		bool v65_n = di_n == 0x00;
		while (cx_n != 0x00)
		{
			v65_n = ds->*di_n == 0x0D;
			di_n = (word16) di_n + 1;
			--cx_n;
			if (ds->*di_n != 0x0D)
				break;
		}
		if (!v65_n)
		{
			di_n.u0 = 0x01;
			es_n.u0 = 0x00;
		}
		if ((di_n - 0x01 | es_n) != 0x00)
		{
			Eq_n es_n = ds;
			byte Eq_n::* di_n = 0x45B2;
			word16 cx_n = ~0x00;
			while (cx_n != 0x00)
			{
				++di_n;
				--cx_n;
				if (ds->*di_n != 0x00)
					break;
			}
			word16 cx_n = ~cx_n;
			struct Eq_n Eq_n::* di_n = di_n - cx_n;
			bool v69_n = di_n == 0x00;
			while (cx_n != 0x00)
			{
				v69_n = (ds->*di_n).b0000 == 0x0D;
				++di_n;
				--cx_n;
				if ((ds->*di_n).b0000 != 0x0D)
					break;
			}
			if (!v69_n)
			{
				di_n = 0x01;
				es_n.u0 = 0x00;
			}
			(es_n->*di_n).bFFFFFFFF = 0x00;
		}
		if (CONVERT(Mem213[ds:0x45B2:byte], int8, int16) == 0x00)
		{
			word16 ax_n = fn0800-2DE2(cx_n, dx_n, si, ds, wArg02_n, out cx_n, out dx_n, out si_n, out ds_n);
			cxOut = cx_n;
			dxOut = dx_n;
			siOut.u0 = <invalid>;
			dsOut = ds;
			return ax_n;
		}
		byte Eq_n::* di_n = 0x45B2;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			byte Eq_n::* di_n;
			di_n = di_n + 1;
			--cx_n;
			di_n = di_n;
			if (ds->*di_n != 0x00)
				break;
		}
		Mem260[ds:0x4619:word16] = -cx_n;
		Eq_n dx_n = fn0800-0C6C(ds, SEQ(ds, 0x45B2));
		if (Mem269[ds:0x464E:word16] == 0x00)
		{
			byte Eq_n::* di_n = 0x45B2;
			word16 cx_n = ~0x00;
			while (cx_n != 0x00)
			{
				++di_n;
				--cx_n;
				if (ds->*di_n != 0x00)
					break;
			}
			cu16 cx_n = ~cx_n;
			<unknown>* di_n = di_n - cx_n;
			uint32 size_n = (cx_n >> 0x01) *32 0x02;
			memcpy(ptrArg02, di_n, size_n);
			memcpy(ptrArg02 + (word16) size_n, &(ds->*((char *) di_n + (word16) size_n)), cond(cx_n >> 0x01) & 0x02);
			Mem387[ds:0x4617:word16] = Mem373[ds:0x4617:word16] + 0x01;
			cxOut.u0 = 0x00;
			dxOut = dx_n;
			siOut.u0 = <invalid>;
			dsOut = ds;
			return 0x01;
		}
		si = fn0800-33CD(ds, fp - 18, 0x00, SEQ(ds, 0x45B2), out cx, out dx);
		Mem325[ds:0x4654:word16] = 0x00;
	}
	ui16 ax_n = Mem492[ds:18002:word16];
	if (ax_n != Mem492[ds:0x4656:word16])
	{
		if (ax_n == Mem492[ds:9882:word16])
		{
			cxOut = cx;
			dxOut = dx;
			siOut.u0 = <invalid>;
			dsOut = ds;
			return 0x00;
		}
		Eq_n es_bx_n = Mem492[ds:9884:segptr32];
		struct Eq_n * es_n = SLICE(es_bx_n, selector, 16);
		union Eq_n Eq_n::* bx_n = SLICE(es_bx_n, word16, 0) + (Mem492[ds:18002:word16] << 0x02);
		fn0800_BF9E(SEQ(ds, 0x45B2), (es_n->*bx_n).u3);
		byte Eq_n::* di_n = 0x45B2;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			byte Eq_n::* di_n;
			di_n = di_n + 1;
			--cx_n;
			di_n = di_n;
			if (ds->*di_n != 0x00)
				break;
		}
		Mem554[ds:0x4619:word16] = -cx_n;
		fn0800-0C6C(ds, SEQ(ds, 0x45B2));
		ui16 ax_n = Mem563[ds:18002:word16];
		Mem574[ds:0x4656:word16] = ax_n;
		Mem575[ds:0x4617:word16] = 0x00;
		if (Mem575[ds:Mem575[ds:9884:word16][ax_n * 0x04] + 0x00:byte] == 0x40)
		{
			Eq_n es_bx_n = Mem716[ds:9884:segptr32];
			struct Eq_n * es_n = SLICE(es_bx_n, selector, 16);
			struct Eq_n Eq_n::* bx_n = SLICE(es_bx_n, word16, 0) + (Mem716[ds:18002:word16] << 0x02);
			Eq_n ax_n = fn0800-4234(ds, SEQ((es_n->*bx_n).w0002, (es_n->*bx_n).w0000 + 0x01), SEQ(ds, 0x0A13), out cx_n, out dx_n, out si_n, out ds_n);
			Mem747[ds_n:17949:word16] = dx_n;
			Mem748[ds_n:17947:word16] = ax_n;
			Mem749[ds_n:0x4654:word16] = 0x01;
			word16 ax_n = fn0800-2DE2(cx_n, dx_n, si_n, ds_n, wArg02_n, out cx_n, out dx_n, out si_n, out ds_n);
			cxOut = cx_n;
			dxOut = dx_n;
			siOut.u0 = <invalid>;
			dsOut = ds_n;
			return ax_n;
		}
		Eq_n dx_n = fn0800-335C(ds, SEQ(ds, 0x45B2));
		if (Mem590[ds:0x464E:word16] == 0x00)
		{
			byte Eq_n::* di_n = 0x45B2;
			word16 cx_n = ~0x00;
			while (cx_n != 0x00)
			{
				++di_n;
				--cx_n;
				if (ds->*di_n != 0x00)
					break;
			}
			cu16 cx_n = ~cx_n;
			<unknown>* di_n = di_n - cx_n;
			uint32 size_n = (cx_n >> 0x01) *32 0x02;
			memcpy(ptrArg02, di_n, size_n);
			memcpy(ptrArg02 + (word16) size_n, &(ds->*((char *) di_n + (word16) size_n)), cond(cx_n >> 0x01) & 0x02);
			Mem699[ds:0x4617:word16] = Mem685[ds:0x4617:word16] + 0x01;
			Mem701[ds:18002:word16] = Mem699[ds:18002:word16] + 0x01;
			cxOut.u0 = 0x00;
			dxOut = dx_n;
			siOut.u0 = <invalid>;
			dsOut = ds;
			return 0x01;
		}
		si = fn0800-33CD(ds, fp - 18, 0x00, SEQ(ds, 0x45B2), out cx, out dx);
	}
	Eq_n si_n = si;
	if (si != 0x00)
	{
		if (Mem794[ds:10779:word16] != 0x00)
		{
			while (si_n != 0x00 && fn0800-31B4(ds, SEQ(ds, 0x45B2), out cx, out dx) != 0x00)
				si_n = fn0800-33CD(ds, fp - 18, 0x00, SEQ(ds, 0x45B2), out cx, out dx);
		}
		Eq_n si_n = si_n;
		if (si_n != 0x00)
		{
			Eq_n bx_n = Mem866[ds:0x4619:word16];
			(ds->*((word32) bx_n + 0x000045B2)).u3 = 0x00;
			if (Mem869[ds:0x4617:word16] == 0x00 && Mem869[ds:18000:word16] != 0x00)
			{
				word16 di_n;
				si_n = fn0800_B2EF(cx, dx, bx_n, ds, SEQ(ds, 0x0A17), out di_n);
			}
			if ((Mem911[ds:17947:word16] | Mem911[ds:17949:word16]) != 0x00)
				Mem921[ds:0x4654:word16] = 0x01;
			else
				Mem919[ds:18002:word16] = Mem911[ds:18002:word16] + 0x01;
			word16 ax_n = fn0800-2DE2(cx, dx, si_n, ds, wArg02_n, out cx_n, out dx_n, out si_n, out ds_n);
			cxOut = cx_n;
			dxOut = dx_n;
			siOut.u0 = <invalid>;
			dsOut = ds;
			return ax_n;
		}
	}
	word16 bx_n;
	fn0800-3509(wArg02_n, wArg04_n, SEQ(ds, 0x45B2), out bx_n);
	byte Eq_n::* di_n = fp - 18;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		struct Eq_n * ss;
		if (ss->*di_n != 0x00)
			break;
	}
	ui16 cx_n = ~cx_n;
	<unknown> Eq_n::* di_n = di_n - cx_n;
	Eq_n di_n = wArg02_n;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		di_n.u3 = &di_n.u5->b0001;
		--cx_n;
		if (wArg04_n->*di_n.u3 != 0x00)
			break;
	}
	memcpy(di_n - 0x01, di_n, (uint32) cx_n);
	Eq_n dx_n = fn0800-0C6C(ds, ptrArg02);
	byte Eq_n::* di_n = 0x4348;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (ds->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	<unknown>* di_n = di_n - cx_n;
	Eq_n cmpResult_n = memcmp(ptrArg02, di_n, (uint32) cx_n);
	Eq_n firstDifference_n = __find_first_difference__(ptrArg02, di_n);
	cui16 ax_n = 0x00;
	Eq_n cx_n = cx_n - firstDifference_n;
	Eq_n si_n;
	si_n.u3 = wArg02_n + firstDifference_n;
	if (cmpResult_n != 0x00)
	{
		cup16 ax_n = 0x00 - (word16) (cmpResult_n < 0x00);
		ax_n = ax_n - ~0x00 - (word16) (ax_n < 0x00);
	}
	if (ax_n != 0x00)
	{
		byte Eq_n::* di_n = 0x4477;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (ds->*di_n != 0x00)
				break;
		}
		word16 cx_n = ~cx_n;
		<unknown>* di_n = di_n - cx_n;
		Eq_n cmpResult_n = memcmp(ptrArg02, di_n, (uint32) cx_n);
		Eq_n firstDifference_n = __find_first_difference__(ptrArg02, di_n);
		cui16 ax_n = 0x00;
		cx_n = cx_n - firstDifference_n;
		si_n.u3 = wArg02_n + firstDifference_n;
		if (cmpResult_n != 0x00)
		{
			cup16 ax_n = 0x00 - (word16) (cmpResult_n < 0x00);
			ax_n = ax_n - ~0x00 - (word16) (ax_n < 0x00);
		}
		if (ax_n != 0x00)
		{
			Mem1246[ds:0x4617:word16] = Mem1186[ds:0x4617:word16] + 0x01;
			cxOut = cx_n;
			dxOut = dx_n;
			siOut.u0 = <invalid>;
			dsOut = ds;
			return 0x01;
		}
	}
	word16 ax_n = fn0800-2DE2(cx_n, dx_n, si_n, ds, wArg02_n, out cx_n, out dx_n, out si_n, out ds_n);
	cxOut = cx_n;
	dxOut = dx_n;
	siOut.u0 = <invalid>;
	dsOut = ds;
	return ax_n;
}

// 0800:31B4: Register word16 fn0800-31B4(Register Eq_n ds, Stack Eq_n dwArg02, Register out Eq_n cxOut, Register out Eq_n dxOut)
// Called from:
//      fn0800-2DE2
word16 fn0800-31B4(Eq_n ds, Eq_n dwArg02, union Eq_n & cxOut, union Eq_n & dxOut)
{
	Eq_n wArg04;
	wArg04.u3 = SLICE(dwArg02, word16, 16);
	Eq_n wArg02 = (word16) dwArg02;
	Eq_n cx_n;
	Eq_n dx_n;
	while (true)
	{
		<unknown> Eq_n::* fp;
		Eq_n ss;
		word16 bx_n;
		fn0800-3509(fp - 0x84, ss, dwArg02, out bx_n);
		word16 dx_n;
		fn0800-35A3(fp - 16, ss, dwArg02, out dx_n);
		if (fn0800-32CD(ds, SEQ(ss, fp - 30), fp - 0x84, ss, ds:0x09AE[Mem54[ds:0x09AC:word16] * 0x02], out cx_n, out dx_n) == 0x00)
			break;
		if (Mem82[ds:0x09AC:word16] == 0x00)
		{
			Mem259[ds:0x09AE:word16] = 0x00;
			cxOut.u0 = <invalid>;
			dxOut.u0 = <invalid>;
			return 0x00;
		}
		byte Eq_n::* di_n = fp - 0x84;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			byte Eq_n::* di_n;
			di_n = di_n + 1;
			--cx_n;
			di_n = di_n;
			if (ss->*di_n != 0x00)
				break;
		}
		ss->*((char *) (fp - 0x84) + (~cx_n - 0x02)) = (<unknown> Eq_n::*) 0x00;
		word16 bx_n;
		fn0800-3509(wArg02, wArg04, SEQ(ss, fp - 0x84), out bx_n);
		byte Eq_n::* di_n = fp - 16;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (ss->*di_n != 0x00)
				break;
		}
		ui16 cx_n = ~cx_n;
		<unknown> Eq_n::* di_n = di_n - cx_n;
		Eq_n di_n = wArg02;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			di_n.u3 = &di_n.u5->b0001;
			--cx_n;
			if (wArg04->*di_n.u3 != 0x00)
				break;
		}
		memcpy(di_n - 0x01, di_n, (uint32) cx_n);
		Mem252[ds:0x09AC:word16] = Mem215[ds:0x09AC:word16] - 0x01;
		ui16 bx_n = Mem252[ds:0x09AC:word16];
		++(*((word32) ds + 0x09AE))[bx_n];
	}
	word16 di_n;
	fn0800_BEA2(cx_n, dx_n, ds, dwArg02, SEQ(ds, 2599), out di_n);
	Mem313[ds:0x09AC:word16] = Mem300[ds:0x09AC:word16] + 0x01;
	ds:0x09AE[Mem313[ds:0x09AC:word16] * 0x02] = 0x00;
	cxOut.u0 = <invalid>;
	dxOut.u0 = <invalid>;
	return 0x01;
}

// 0800:32CD: Register word16 fn0800-32CD(Register Eq_n ds, Stack Eq_n dwArg02, Stack (memptr Eq_n byte) wArg06, Stack Eq_n psegArg08, Stack word16 wArg0A, Register out word16 cxOut, Register out word16 dxOut)
// Called from:
//      fn0800-31B4
word16 fn0800-32CD(Eq_n ds, Eq_n dwArg02, byte Eq_n::* wArg06, Eq_n psegArg08, word16 wArg0A, word16 & cxOut, word16 & dxOut)
{
	byte Eq_n::* di_n = wArg06;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (psegArg08->*di_n != 0x00)
			break;
	}
	cu16 cx_n = ~cx_n;
	<unknown>* di_n = di_n - cx_n;
	uint32 size_n = (cx_n >> 0x01) *32 0x02;
	mp16 fp;
	memcpy(fp - 0x0068, di_n, size_n);
	memcpy(fp - 0x0068 + (word16) size_n, &(psegArg08->*((char *) di_n + (word16) size_n)), cond(cx_n >> 0x01) & 0x02);
	byte Eq_n::* di_n = fp - 0x0068;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		struct Eq_n * ss;
		if (ss->*di_n != 0x00)
			break;
	}
	memcpy(di_n - 0x01, *((word32) ds + 0x0A32), 0x04);
	word16 cx_n;
	word16 dx_n;
	if (fn0800-33CD(ds, dwArg02, 0x10, fp - 0x0068, out cx_n, out dx_n) == 0x00)
	{
		while (wArg0A != 0x00 && fn0800-3479(ds, dwArg02, 0x10, out cx_n, out dx_n) == 0x00)
			--wArg0A;
		cxOut = cx_n;
		dxOut = dx_n;
		return wArg0A;
	}
	else
	{
		cxOut = cx_n;
		dxOut = dx_n;
		return 0x01;
	}
}

// 0800:335C: Register word16 fn0800-335C(Register Eq_n ds, Stack Eq_n ptrArg02)
// Called from:
//      fn0800-2DE2
word16 fn0800-335C(Eq_n ds, Eq_n ptrArg02)
{
	struct Eq_n * wArg04 = SLICE(ptrArg02, word16, 16);
	byte Eq_n::* wArg02 = (word16) ptrArg02;
	Eq_n ss;
	<unknown> Eq_n::* fp;
	word16 cx_n;
	word16 dx_n;
	if (fn0800-33CD(ds, SEQ(ss, fp - 16), 0x10, ptrArg02, out cx_n, out dx_n) == 0x00)
	{
		fn0800-35A3(fp - 30, ss, ptrArg02, out dx_n);
		byte Eq_n::* di_n = fp - 30;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (ss->*di_n != 0x00)
				break;
		}
		ui16 cx_n = ~cx_n;
		cui16 ax_n = 0x00;
		Eq_n cmpResult_n = memcmp(fp - 16, di_n - cx_n, (uint32) cx_n);
		if (cmpResult_n != 0x00)
		{
			cup16 ax_n = 0x00 - (word16) (cmpResult_n < 0x00);
			ax_n = ax_n - ~0x00 - (word16) (ax_n < 0x00);
		}
		if (ax_n == 0x00)
		{
			byte Eq_n::* di_n = wArg02;
			word16 cx_n = ~0x00;
			while (cx_n != 0x00)
			{
				++di_n;
				--cx_n;
				if (wArg04->*di_n != 0x00)
					break;
			}
			memcpy(di_n - 0x01, *((word32) ds + 0x0A36), 0x05);
		}
	}
	return dx_n;
}

// 0800:33CD: Register Eq_n fn0800-33CD(Register Eq_n ds, Stack Eq_n ptrArg02, Stack cui16 wArg06, Stack Eq_n dwArg08, Register out word16 cxOut, Register out word16 dxOut)
// Called from:
//      fn0800-2DE2
//      fn0800-32CD
//      fn0800-335C
//      fn0800-3678
Eq_n fn0800-33CD(Eq_n ds, Eq_n ptrArg02, cui16 wArg06, Eq_n dwArg08, word16 & cxOut, word16 & dxOut)
{
	word16 dx_n;
	word16 cx_n;
	word16 cx_n;
	word16 dx_n;
	if (fn0800_A817(0x23, ds, dwArg08, SEQ(ds, 17955), wArg06, out cx_n, out dx_n) == 0x00)
	{
		word16 ax_n = 0x00;
		Eq_n cmpResult_n = memcmp(*((word32) ds + 0x00004641), *((word32) ds + 0x0A3B), 0x02);
		if (cmpResult_n != 0x00)
		{
			cup16 ax_n = 0x00 - (word16) (cmpResult_n < 0x00);
			ax_n = ax_n - ~0x00 - (word16) (ax_n < 0x00);
		}
		if (ax_n != 0x00)
		{
			Eq_n cmpResult_n = memcmp(*((word32) ds + 0x00004641), *((word32) ds + 2621), 0x03);
			word16 ax_n = 0x00;
			word16 cx_n = 0x03 - __find_first_difference__(*((word32) ds + 0x00004641), *((word32) ds + 2621));
			if (cmpResult_n != 0x00)
			{
				cup16 ax_n = 0x00 - (word16) (cmpResult_n < 0x00);
				ax_n = ax_n - ~0x00 - (word16) (ax_n < 0x00);
			}
			if (ax_n != 0x00 && (CONVERT(Mem79[ds:17976:byte], int8, int16) & wArg06) == wArg06)
			{
				if (ptrArg02 != 0x00)
				{
					byte Eq_n::* di_n = 0x4641;
					word16 cx_n = ~0x00;
					while (cx_n != 0x00)
					{
						++di_n;
						--cx_n;
						if (ds->*di_n != 0x00)
							break;
					}
					cu16 cx_n = ~cx_n;
					<unknown>* di_n = di_n - cx_n;
					uint32 size_n = (cx_n >> 0x01) *32 0x02;
					memcpy(ptrArg02, di_n, size_n);
					memcpy(ptrArg02 + (word16) size_n, &(ds->*((char *) di_n + (word16) size_n)), cond(cx_n >> 0x01) & 0x02);
					cx_n = 0x00;
				}
				cxOut = cx_n;
				dxOut = dx_n;
				return 0x00;
			}
		}
		Eq_n ax_n = fn0800-3479(ds, ptrArg02, wArg06, out cx_n, out dx_n);
		cxOut = cx_n;
		dxOut = dx_n;
		return ax_n;
	}
	else
	{
		cxOut = cx_n;
		dxOut = dx_n;
		return 0x01;
	}
}

// 0800:3479: Register word16 fn0800-3479(Register Eq_n ds, Stack Eq_n ptrArg02, Stack cui16 wArg06, Register out word16 cxOut, Register out Eq_n dxOut)
// Called from:
//      fn0800-2DE2
//      fn0800-32CD
//      fn0800-33CD
word16 fn0800-3479(Eq_n ds, Eq_n ptrArg02, cui16 wArg06, word16 & cxOut, union Eq_n & dxOut)
{
	word16 ax_n;
	word16 cx_n;
	do
	{
		word16 cx_n;
		word16 dx_n;
		if (fn0800_A84A(0x23, ds, SEQ(ds, 17955), out cx_n, out dx_n) != 0x00)
		{
			cxOut = cx_n;
			dxOut.u0 = <invalid>;
			return 0x01;
		}
		word16 ax_n = 0x00;
		Eq_n cmpResult_n = memcmp(*((word32) ds + 0x00004641), *((word32) ds + 0x0A3B), 0x02);
		if (cmpResult_n != 0x00)
		{
			cup16 ax_n = 0x00 - (word16) (cmpResult_n < 0x00);
			ax_n = ax_n - ~0x00 - (word16) (ax_n < 0x00);
		}
		if (ax_n == 0x00)
			continue;
		Eq_n cmpResult_n = memcmp(*((word32) ds + 0x00004641), *((word32) ds + 2621), 0x03);
		ax_n = 0x00;
		cx_n = 0x03 - __find_first_difference__(*((word32) ds + 0x00004641), *((word32) ds + 2621));
		if (cmpResult_n != 0x00)
		{
			cup16 ax_n = 0x00 - (word16) (cmpResult_n < 0x00);
			ax_n = ax_n - ~0x00 - (word16) (ax_n < 0x00);
		}
	} while (ax_n == 0x00 || (CONVERT(Mem72[ds:17976:byte], int8, int16) & wArg06) != wArg06);
	if (ptrArg02 != 0x00)
	{
		byte Eq_n::* di_n = 0x4641;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (ds->*di_n != 0x00)
				break;
		}
		cu16 cx_n = ~cx_n;
		<unknown>* di_n = di_n - cx_n;
		uint32 size_n = (cx_n >> 0x01) *32 0x02;
		memcpy(ptrArg02, di_n, size_n);
		memcpy(ptrArg02 + (word16) size_n, &(ds->*((char *) di_n + (word16) size_n)), cond(cx_n >> 0x01) & 0x02);
		cx_n = 0x00;
	}
	cxOut = cx_n;
	dxOut.u0 = <invalid>;
	return 0x00;
}

// 0800:3509: Register Eq_n fn0800-3509(Stack Eq_n wArg02, Stack Eq_n psegArg04, Stack Eq_n dwArg06, Register out word16 bxOut)
// Called from:
//      fn0800-0C93
//      fn0800-12E2
//      fn0800-19EE
//      fn0800-29C5
//      fn0800-2DE2
//      fn0800-31B4
//      fn0800-3764
//      fn0800-37DF
//      fn0800-3992
//      fn0800-3C99
Eq_n fn0800-3509(Eq_n wArg02, Eq_n psegArg04, Eq_n dwArg06, word16 & bxOut)
{
	<unknown> Eq_n::* fp;
	word16 bx_n = fn0800_BE3B(dwArg06, fp - 6, fp - 90, fp - 16, fp - 22);
	byte Eq_n::* di_n = fp - 6;
	word16 cx_n = ~0x00;
	struct Eq_n * ss;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (ss->*di_n != 0x00)
			break;
	}
	uint16 cx_n = ~cx_n;
	<unknown>* di_n = di_n - cx_n;
	uint32 size_n = (cx_n >> 0x01) *32 0x02;
	memcpy(&(psegArg04->*wArg02.u3), di_n, size_n);
	memcpy(&(psegArg04->*(wArg02.u3 + (word16) size_n)), &(ss->*((char *) di_n + (word16) size_n)), cond(cx_n >> 0x01) & 0x02);
	byte Eq_n::* di_n = fp - 90;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (ss->*di_n != 0x00)
			break;
	}
	ui16 cx_n = ~cx_n;
	<unknown> Eq_n::* di_n = di_n - cx_n;
	Eq_n di_n = wArg02;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		di_n.u3 = &di_n.u5->b0001;
		--cx_n;
		if (psegArg04->*di_n.u3 != 0x00)
			break;
	}
	memcpy(di_n - 0x01, di_n, (uint32) cx_n);
	bxOut = bx_n;
	return psegArg04;
}

// 0800:35A3: Register byte fn0800-35A3(Stack Eq_n wArg02, Stack Eq_n psegArg04, Stack Eq_n dwArg06, Register out Eq_n dxOut)
// Called from:
//      fn0800-0ABC
//      fn0800-12E2
//      fn0800-19EE
//      fn0800-29C5
//      fn0800-31B4
//      fn0800-335C
//      fn0800-37DF
//      fn0800-3992
byte fn0800-35A3(Eq_n wArg02, Eq_n psegArg04, Eq_n dwArg06, union Eq_n & dxOut)
{
	<unknown> Eq_n::* fp;
	fn0800_BE3B(dwArg06, fp - 6, fp - 90, fp - 16, fp - 22);
	byte Eq_n::* di_n = fp - 16;
	word16 cx_n = ~0x00;
	struct Eq_n * ss;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (ss->*di_n != 0x00)
			break;
	}
	uint16 cx_n = ~cx_n;
	<unknown>* di_n = di_n - cx_n;
	uint32 size_n = (cx_n >> 0x01) *32 0x02;
	memcpy(&(psegArg04->*wArg02.u3), di_n, size_n);
	memcpy(&(psegArg04->*(wArg02.u3 + (word16) size_n)), &(ss->*((char *) di_n + (word16) size_n)), cond(cx_n >> 0x01) & 0x02);
	byte Eq_n::* di_n = fp - 22;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (ss->*di_n != 0x00)
			break;
	}
	ui16 cx_n = ~cx_n;
	<unknown> Eq_n::* di_n = di_n - cx_n;
	Eq_n di_n = wArg02;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		di_n.u3 = &di_n.u5->b0001;
		--cx_n;
		if (psegArg04->*di_n.u3 != 0x00)
			break;
	}
	memcpy(di_n - 0x01, di_n, (uint32) cx_n);
	dxOut = psegArg04;
	return 0x00;
}

// 0800:363D: Register word16 fn0800-363D(Register Eq_n ds, Stack (ptr32 Eq_n) ptrArg02, Stack Eq_n dwArg06, Register out word16 dxOut)
// Called from:
//      fn0800-388C
//      fn0800-3992
word16 fn0800-363D(Eq_n ds, struct Eq_n * ptrArg02, Eq_n dwArg06, word16 & dxOut)
{
	<unknown> Eq_n::* fp;
	word16 cx_n;
	word16 dx_n;
	if (fn0800_A817((byte) fp - 0x2E, ds, dwArg06, fp - 46, 0x00, out cx_n, out dx_n) != 0x00)
		return;
	word16 wLoc18;
	ptrArg02->w0000 = wLoc18;
	word16 wLoc16;
	ptrArg02->w0002 = wLoc16;
	return;
}

// 0800:3678: Register word16 fn0800-3678(Register Eq_n ds, Stack Eq_n ptrArg02, Register out cui16 dxOut, Register out word16 siOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-0DE8
//      fn0800-112D
//      fn0800-19EE
word16 fn0800-3678(Eq_n ds, Eq_n ptrArg02, cui16 & dxOut, word16 & siOut, union Eq_n & dsOut)
{
	struct Eq_n * wArg04 = SLICE(ptrArg02, word16, 16);
	Eq_n wArg02 = (word16) ptrArg02;
	struct Eq_n * es_n = wArg04;
	Eq_n di_n = wArg02;
	word16 cx_n = ~0x00;
	Eq_n ptrLoc06_n = ptrArg02;
	while (cx_n != 0x00)
	{
		di_n = (word16) di_n + 1;
		--cx_n;
		if (wArg04->*di_n != 0x00)
			break;
	}
	word16 cx_n = ~cx_n;
	byte Eq_n::* di_n = di_n - cx_n;
	bool v33_n = di_n == &Eq_n::b0000;
	while (cx_n != 0x00)
	{
		v33_n = wArg04->*di_n == 0x5C;
		++di_n;
		--cx_n;
		if (wArg04->*di_n != 0x5C)
			break;
	}
	if (!v33_n)
	{
		di_n = &Eq_n::b0001;
		es_n = 0x00;
	}
	Eq_n di_n = di_n - 0x01;
	if ((di_n | es_n) != 0x00)
	{
		struct Eq_n * ptrLoc0A_n = (struct Eq_n *) di_n;
		if (es_n == wArg04 && di_n == wArg02 || ptrLoc0A_n->bFFFFFFFF == 0x3A)
			ptrLoc06_n.u3 = (word16) di_n + 1;
	}
	word16 cx_n;
	cui16 dx_n;
	word16 si;
	while (true)
	{
		struct Eq_n * es_n = SLICE(ptrLoc06_n, selector, 16);
		byte Eq_n::* di_n = (word16) ptrLoc06_n;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		cx_n = ~cx_n;
		byte Eq_n::* di_n = di_n - cx_n;
		bool v37_n = di_n == &Eq_n::b0000;
		while (cx_n != 0x00)
		{
			v37_n = es_n->*di_n == 0x5C;
			++di_n;
			--cx_n;
			if (es_n->*di_n != 0x5C)
				break;
		}
		if (!v37_n)
		{
			di_n = &Eq_n::b0001;
			es_n = 0x00;
		}
		Eq_n di_n = di_n - 0x01;
		dx_n = di_n | es_n;
		byte * ptrLoc0A_n = (byte *) di_n;
		if (dx_n == 0x00)
			break;
		*ptrLoc0A_n = 0x00;
		word16 cx_n;
		word16 dx_n;
		if (fn0800-33CD(ds, 0x00, 0x10, ptrArg02, out cx_n, out dx_n) != 0x00 && fn0800-8E52(ds, ptrArg02) != 0x00)
		{
			word16 cx_n;
			word16 dx_n;
			word16 bx_n;
			word16 di_n;
			fn0800-0D24(ds, 0x0E, ptrArg02, out cx_n, out dx_n, out bx_n, out si, out di_n, out ds);
		}
		*ptrLoc0A_n = 0x5C;
		ptrLoc06_n.u3 = (word16) di_n + 1;
	}
	dxOut = dx_n;
	siOut = si;
	dsOut = ds;
	return cx_n;
}

// 0800:3764: void fn0800-3764(Register Eq_n ds)
// Called from:
//      fn0800-0DE8
//      fn0800-112D
void fn0800-3764(Eq_n ds)
{
	if (Mem10[ds:17022:byte] != 0x00)
	{
		byte Eq_n::* di_n = 17022;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (ds->*di_n != 0x00)
				break;
		}
		cu16 cx_n = ~cx_n;
		<unknown>* di_n = di_n - cx_n;
		uint32 size_n = (cx_n >> 0x01) *32 0x02;
		memcpy(*((word32) ds + 0x000044DC), di_n, size_n);
		memcpy((word16) size_n + 0x44DC, &(ds->*((char *) di_n + (word16) size_n)), cond(cx_n >> 0x01) & 0x02);
	}
	else
	{
		word16 bx_n;
		fn0800-3509(0x44DC, ds, SEQ(ds, 0x4541), out bx_n);
	}
	byte Eq_n::* di_n = 0x44DC;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (ds->*di_n != 0x00)
			break;
	}
	memcpy(di_n - 0x01, *((word32) ds + 2624), 0x0D);
}

// 0800:37BE: Register word16 fn0800-37BE(Register Eq_n cx, Register Eq_n dx, Register Eq_n ds, Stack Eq_n dwArg02)
// Called from:
//      fn0800-0DE8
//      fn0800-12E2
//      fn0800-19EE
//      fn0800-3BC3
word16 fn0800-37BE(Eq_n cx, Eq_n dx, Eq_n ds, Eq_n dwArg02)
{
	word16 di_n;
	return fn0800_BEA2(cx, dx, ds, dwArg02, SEQ(ds, 0x0A2B), out di_n);
}

// 0800:37DF: Register word16 fn0800-37DF(Register Eq_n ds, Register out Eq_n dsOut)
// Called from:
//      fn0800-0DE8
//      fn0800-112D
word16 fn0800-37DF(Eq_n ds, union Eq_n & dsOut)
{
	Eq_n ds_n;
	word16 cx_n;
	mp16 fp;
	Eq_n ss;
	word16 bx_n;
	fn0800-3509(fp - 0x006C, ss, SEQ(ds, 0x44DC), out bx_n);
	Eq_n es_n = ss;
	byte Eq_n::* di_n = fp - 0x006C;
	word16 cx_n = ~0x00;
	Eq_n dwLoc72_n = SEQ(ds, 0x4541);
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (ss->*di_n != 0x00)
			break;
	}
	ui16 cx_n = ~cx_n;
	byte Eq_n::* di_n = di_n - cx_n;
	bool v27_n = di_n == 0x00;
	while (cx_n != 0x00)
	{
		v27_n = ss->*di_n == 0x00;
		++di_n;
		--cx_n;
		if (ss->*di_n != 0x00)
			break;
	}
	if (!v27_n)
	{
		di_n = 0x01;
		es_n.u0 = 0x00;
	}
	word16 dx_n;
	fn0800-35A3(di_n - 0x01, es_n, dwLoc72_n, out dx_n);
	Eq_n dx_ax_n = fn0800_AA7E(ds, SEQ(ss, fp - 0x006C), SEQ(ds, 0x0A4D), out cx_n, out ds_n);
	if (dx_ax_n != 0x00)
	{
		fn0800_A614(ds_n, dx_ax_n, out ds_n);
		fn0800_A4F6(ds_n, 0x0180);
		fn0800-8F7F(ds_n, SEQ(ss, fp - 0x006C));
	}
	word16 si;
	if (fn0800_BA4A(ds_n, SEQ(ds_n, 0x44DC), SEQ(ss, fp - 0x006C)) == ~0x00)
	{
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		word16 di_n;
		fn0800-0D24(ds_n, 0x0A, SEQ(ds_n, 0x44DC), out cx_n, out dx_n, out bx_n, out si, out di_n, out ds_n);
	}
	dsOut = ds_n;
	return si;
}

// 0800:388C: Register word16 fn0800-388C(Register Eq_n ds, Register out word16 cxOut, Register out word16 dxOut, Register out Eq_n siOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-0DE8
//      fn0800-112D
word16 fn0800-388C(Eq_n ds, word16 & cxOut, word16 & dxOut, union Eq_n & siOut, union Eq_n & dsOut)
{
	Eq_n ds_n;
	word16 dx_n;
	word16 dx_n;
	<unknown> Eq_n::* fp;
	Eq_n ds_n;
	word16 si_n;
	Eq_n dx_n;
	word16 cx_n;
	Eq_n ds_n;
	word16 si_n;
	Eq_n dx_n;
	word16 cx_n;
	Eq_n ax_n = fn0800-4234(ds, SEQ(ds, 0x4541), SEQ(ds, 0x0A13), out cx_n, out dx_n, out si_n, out ds_n);
	Mem36[ds_n:0x29E5:word16] = dx_n;
	Mem37[ds_n:0x29E3:word16] = ax_n;
	Eq_n ax_n = fn0800-4234(ds_n, SEQ(ds_n, 0x44DC), SEQ(ds_n, 0x0A50), out cx_n, out dx_n, out si_n, out ds_n);
	Mem62[ds_n:10721:word16] = dx_n;
	Mem63[ds_n:10719:word16] = ax_n;
	word16 cx_n = fn0800-363D(ds_n, fp - 6, SEQ(ds_n, 0x44DC), out dx_n);
	if (Mem73[ds_n:0x0A12:byte] != 0x00)
	{
		word16 cx_n = fn0800-363D(ds_n, fp - 0x0A, SEQ(ds_n, 0x4541), out dx_n);
		if (fn0800-395B(fp - 0x0A, SEQ(ds_n, 17951)) < 0x00 || fn0800-395B(fp - 0x0A, fp - 6) > 0x00)
		{
			cxOut = cx_n;
			dxOut = dx_n;
			siOut.u0 = <invalid>;
			dsOut = ds_n;
			return 0x01;
		}
		else
		{
			Eq_n ds_n;
			fn0800_A614(ds_n, Mem144[ds_n:0x29E3:word32], out ds_n);
			word16 cx_n = fn0800_A614(ds_n, Mem163[ds_n:10719:word32], out ds_n);
			word16 dx_n = fn0800-8F7F(ds_n, SEQ(ds_n, 0x44DC));
			cxOut = cx_n;
			dxOut = dx_n;
			siOut.u0 = <invalid>;
			dsOut = ds_n;
			return 0x00;
		}
	}
	else
	{
		word16 wLoc04;
		Mem223[ds_n:0x4621:word16] = wLoc04;
		word16 wLoc06;
		Mem225[ds_n:17951:word16] = wLoc06;
		Mem226[ds_n:0x0A12:byte] = 0x01;
		cxOut = cx_n;
		dxOut = dx_n;
		siOut.u0 = <invalid>;
		dsOut = ds_n;
		return 0x01;
	}
}

// 0800:395B: Register word16 fn0800-395B(Stack (ptr32 Eq_n) ptrArg02, Stack (ptr32 Eq_n) ptrArg06)
// Called from:
//      fn0800-388C
//      fn0800-3992
word16 fn0800-395B(struct Eq_n * ptrArg02, struct Eq_n * ptrArg06)
{
	word16 ax_n = ptrArg02->w0002;
	if (ax_n != ptrArg06->w0002)
		return ax_n - ptrArg06->w0002;
	return ptrArg02->w0000 - ptrArg06->w0000;
}

// 0800:3992: Register word16 fn0800-3992(Register Eq_n ds, Register out Eq_n dsOut)
// Called from:
//      fn0800-0DE8
word16 fn0800-3992(Eq_n ds, union Eq_n & dsOut)
{
	Eq_n ds_n;
	Eq_n ds_n;
	Eq_n ds_n;
	Eq_n ds_n;
	word16 cx_n;
	if (Mem12[ds:17022:byte] == 0x00 || (Mem12[ds:0x2A23:word16] != 0x01 || Mem12[ds:10775:word16] == 0x00))
	{
		dsOut = ds;
		return 0x00;
	}
	else
	{
		mp16 fp;
		Eq_n ss;
		word16 bx_n;
		fn0800-3509(fp - 116, ss, SEQ(ds, 0x44DC), out bx_n);
		Eq_n es_n = ss;
		byte Eq_n::* di_n = fp - 116;
		word16 cx_n = ~0x00;
		Eq_n dwLoc7A_n = SEQ(ds, 0x4541);
		while (cx_n != 0x00)
		{
			++di_n;
			--cx_n;
			if (ss->*di_n != 0x00)
				break;
		}
		ui16 cx_n = ~cx_n;
		byte Eq_n::* di_n = di_n - cx_n;
		bool v46_n = di_n == 0x00;
		while (cx_n != 0x00)
		{
			v46_n = ss->*di_n == 0x00;
			++di_n;
			--cx_n;
			if (ss->*di_n != 0x00)
				break;
		}
		if (!v46_n)
		{
			di_n = 0x01;
			es_n.u0 = 0x00;
		}
		word16 dx_n;
		fn0800-35A3(di_n - 0x01, es_n, dwLoc7A_n, out dx_n);
		Eq_n dx_ax_n = fn0800_AA7E(ds, SEQ(ss, fp - 116), SEQ(ds, 0x0A4D), out cx_n, out ds_n);
		if (dx_ax_n != 0x00)
		{
			Eq_n dx_ax_n = fn0800-4194(ds_n, dx_ax_n);
			cup16 ax_n = (word16) dx_ax_n;
			cup16 dx_n = SLICE(dx_ax_n, word16, 16);
			if (dx_n > 0x00 || dx_n == 0x00 && ax_n > 0x12)
			{
				int32 dx_ax_n = fn0800-8CAA(fn0800-3E5D(ds_n, dx_ax_n, out ds_n), 0x08);
				word16 ax_n = (word16) dx_ax_n;
				if (SLICE(dx_ax_n, word16, 16) != 0x52 || ax_n != 0x4E43)
				{
					Eq_n ds_n;
					fn0800_A614(ds_n, dx_ax_n, out ds_n);
					dsOut = ds_n;
					return 0x00;
				}
				else
				{
					Eq_n dx_ax_n = fn0800-3E5D(ds_n, dx_ax_n, out ds_n);
					Eq_n ax_n = (word16) dx_ax_n;
					if (SLICE(dx_ax_n, word16, 16) != Mem229[ds_n:0x2A09:word16] || ax_n != Mem229[ds_n:0x2A07:word16])
					{
						Eq_n ds_n;
						fn0800_A614(ds_n, dx_ax_n, out ds_n);
						dsOut = ds_n;
						return 0x00;
					}
					else
					{
						word16 dx_n;
						fn0800-363D(ds_n, SEQ(ss, fp - 0x0E), SEQ(ss, fp - 116), out dx_n);
						word16 dx_n;
						fn0800-363D(ds_n, SEQ(ss, fp - 0x0A), SEQ(ds_n, 0x4541), out dx_n);
						if (fn0800-395B(SEQ(ss, fp - 0x0E), SEQ(ss, fp - 0x0A)) >= 0x00)
						{
							Eq_n dx_ax_n = fn0800-3E5D(ds_n, dx_ax_n, out ds_n);
							Mem339[ds_n:0x2A05:word16] = SLICE(dx_ax_n + 0x12, word16, 16);
							Mem340[ds_n:0x2A03:word16] = SLICE(dx_ax_n, word16, 0) + 0x12;
							Eq_n ds_n;
							fn0800_A614(ds_n, dx_ax_n, out ds_n);
							dsOut = ds_n;
							return 0x01;
						}
						else
						{
							Eq_n ds_n;
							fn0800_A614(ds_n, dx_ax_n, out ds_n);
							dsOut = ds_n;
							return 0x00;
						}
					}
				}
			}
			else
			{
				Eq_n ds_n;
				fn0800_A614(ds_n, dx_ax_n, out ds_n);
				dsOut = ds_n;
				return 0x00;
			}
		}
		else
		{
			dsOut = ds_n;
			return 0x00;
		}
	}
}

// 0800:3B0A: Register word16 fn0800-3B0A(Register Eq_n ds, Stack Eq_n wArg0A, Stack Eq_n wArg0C, Register out word16 siOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-0DE8
//      fn0800-12E2
//      fn0800-3BC3
//      fn0800-3C99
//      fn0800-46FE
//      fn0800-4BB1
//      fn0800-4F2C
//      fn0800-51A9
//      fn0800-5374
//      fn0800-5E64
//      fn0800-67BF
//      fn0800-6F20
//      fn0800-741D
word16 fn0800-3B0A(Eq_n ds, Eq_n wArg0A, Eq_n wArg0C, word16 & siOut, union Eq_n & dsOut)
{
	Eq_n ds_n;
	Eq_n dx_n;
	mp16 fp;
	struct Eq_n Eq_n::* bp_n = fp - 2;
	word16 si;
	selector ss;
	if ((wArg0A | wArg0C) != 0x00)
	{
		Eq_n dx_ax_n;
		if (wArg0C >= 0x00 && (wArg0C > 0x00 || wArg0A > 65000))
			dx_ax_n.u0 = 65000;
		else
			dx_ax_n = SEQ(wArg0C, wArg0A);
		Eq_n ax_n = fn0800-4311(ds, dx_ax_n, out dx_n, out bp_n, out si, out ds_n);
		(ss->*bp_n).tFFFFFFFE.u2 = (uint16) dx_n;
		(ss->*bp_n).tFFFFFFFC.u2 = (uint16) ax_n;
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		while (((ss->*bp_n).t000C.u2 | ((ss->*bp_n).t000E).u2) != 0x00)
		{
			Eq_n dx_n;
			Eq_n ax_n;
			if ((ss->*bp_n).t000E.u2 >= 0x00 && (((ss->*bp_n).t000E).u2 > 0x00 || ((ss->*bp_n).t000C).u2 > 65000))
			{
				dx_n.u0 = 0x00;
				ax_n.u0 = 65000;
			}
			else
			{
				dx_n.u2 = (ss->*bp_n).t000E.u2;
				ax_n.u2 = (ss->*bp_n).t000C.u2;
			}
			(ss->*bp_n).tFFFFFFFA.u2 = (uint16) dx_n;
			(ss->*bp_n).tFFFFFFF8.u2 = (uint16) ax_n;
			(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).t0006.u2;
			(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).t0004.u2;
			(ss->*((word32) sp_n - 2)).u2 = (ss->*bp_n).tFFFFFFFA.u2;
			ss->*((word32) sp_n - 4) = ax_n;
			(ss->*((word32) sp_n - 6)).u2 = (ss->*bp_n).tFFFFFFFE.u2;
			(ss->*((word32) sp_n - 8)).u2 = (ss->*bp_n).tFFFFFFFC.u2;
			word16 si_n;
			word16 di_n;
			Eq_n ds_n;
			fn0800-4110(ds_n, ss->*((word32) sp_n - 8), ss->*((word32) sp_n - 4), ss->*((word32) sp_n - 2), ss->*sp_n.u4, out si_n, out di_n, out ds_n);
			(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).t000A.u2;
			(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).t0008.u2;
			(ss->*((word32) sp_n - 2)).u2 = (ss->*bp_n).tFFFFFFFA.u2;
			(ss->*((word32) sp_n - 4)).u2 = (ss->*bp_n).tFFFFFFF8.u2;
			(ss->*((word32) sp_n - 6)).u2 = (ss->*bp_n).tFFFFFFFE.u2;
			(ss->*((word32) sp_n - 8)).u2 = (ss->*bp_n).tFFFFFFFC.u2;
			fn0800-4152(ds_n, ss->*((word32) sp_n - 8), ss->*((word32) sp_n - 4), ss->*((word32) sp_n - 2), ss->*sp_n.u4, out si, out ds_n);
			(ss->*bp_n).t000C.u3 = (char *) ((ss->*bp_n).t000C.u3 - ((ss->*bp_n).tFFFFFFF8).u3);
		}
		(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFFE.u2;
		(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).tFFFFFFFC.u2;
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		fn0800-4346(ds_n, (ss->*sp_n.u5).t0002.u1.u2, out cx_n, out dx_n, out bx_n, out ds);
	}
	word16 bp_n = (ss->*bp_n).w0000;
	siOut = si;
	dsOut = ds;
	return bp_n;
}

// 0800:3BC3: Register Eq_n fn0800-3BC3(Register Eq_n cx, Register Eq_n dx, Register Eq_n ds, Stack Eq_n dwArg02, Stack Eq_n dwArg06, Register out uint16 siOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-1E5E
Eq_n fn0800-3BC3(Eq_n cx, Eq_n dx, Eq_n ds, Eq_n dwArg02, Eq_n dwArg06, uint16 & siOut, union Eq_n & dsOut)
{
	Eq_n ds_n;
	uint16 si_n;
	Eq_n ds_n;
	word16 si_n;
	Eq_n ds_n;
	word16 si_n;
	Eq_n dx_n;
	word16 cx_n;
	fn0800-37BE(cx, dx, ds, SEQ(ds, 0x43AD));
	Eq_n ax_n = fn0800-4234(ds, SEQ(ds, 0x43AD), SEQ(ds, 0x0A61), out cx_n, out dx_n, out si_n, out ds_n);
	Mem60[ds_n:10709:word16] = dx_n;
	Mem61[ds_n:10707:word16] = ax_n;
	ui32 dx_ax_n = fn0800-4194(ds_n, dwArg02) - dwArg06;
	word16 cx_n;
	fn0800_ACB3(ds_n, dwArg02, dwArg06, 0x00, out cx_n);
	struct Eq_n Eq_n::* bp_n = fn0800-3B0A(ds_n, (word16) dx_ax_n, SLICE(dx_ax_n, word16, 16), out si_n, out ds_n);
	Eq_n sp_n;
	sp_n.u0 = <invalid>;
	selector ss;
	Mem151[ss:sp_n + 0x0A:word16] = Mem132[ds_n:10709:word16];
	Mem154[ss:sp_n + 0x08:word16] = Mem151[ds_n:10707:word16];
	fn0800_BA67(ds_n, (ss->*sp_n.u5).t0008.u3);
	(ss->*sp_n.u5).t000A.u2 = (uint16) 0x00;
	ui32 ax_dx_n = (ss->*bp_n).t000C.u3 + ((ss->*bp_n).t0008).u0;
	(ss->*sp_n.u5).t0008.u2 = SLICE(ax_dx_n, word16, 16);
	(ss->*sp_n.u5).t0006.u2 = (uint16) (word16) ax_dx_n;
	(ss->*sp_n.u5).t0004.u1.u2 = (ss->*bp_n).t0006.u2;
	(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).t0004.u2;
	word16 cx_n;
	fn0800_ACB3(ds_n, (ss->*sp_n.u5).t0002.u1.u3, (ss->*sp_n.u5).t0006.u3, (ss->*sp_n.u5).t000A.u2, out cx_n);
	(ss->*sp_n.u5).t000A.u2 = (ss->*bp_n).tFFFFFFFE.u2;
	(ss->*sp_n.u5).t0008.u2 = (ss->*bp_n).tFFFFFFFC.u2;
	(ss->*sp_n.u5).t0006.u2 = (ss->*bp_n).t0006.u2;
	(ss->*sp_n.u5).t0004.u1.u2 = (ss->*bp_n).t0004.u2;
	Mem212[ss:sp_n + 0x02:word16] = Mem209[ds_n:10709:word16];
	Mem215[ss:sp_n + 0x00:word16] = Mem212[ds_n:10707:word16];
	struct Eq_n Eq_n::* bp_n = fn0800-3B0A(ds_n, (ss->*sp_n.u5).t0008.u2, (ss->*sp_n.u5).t000A.u2, out si_n, out ds_n);
	Eq_n sp_n;
	sp_n.u0 = <invalid>;
	Mem234[ss:sp_n + 0x0A:word16] = Mem215[ds_n:10709:word16];
	Mem237[ss:sp_n + 0x08:word16] = Mem234[ds_n:10707:word16];
	Eq_n ds_n;
	fn0800_A614(ds_n, (ss->*sp_n.u5).t0008.u3, out ds_n);
	(ss->*sp_n.u5).t000A.u2 = (uint16) ds_n;
	(ss->*sp_n.u5).t0008.u2 = (uint16) 0x43AD;
	fn0800-8F7F(ds_n, (ss->*sp_n.u5).t0008.u3);
	Eq_n bp_n;
	bp_n.u2 = (ss->*bp_n).t0000.u2;
	siOut = si_n;
	dsOut = ds_n;
	return bp_n;
}

// 0800:3C99: Register byte fn0800-3C99(Register Eq_n ds, Stack Eq_n dwArg02, Stack Eq_n wArg06, Stack Eq_n wArg08, Register out Eq_n bpOut, Register out uint16 siOut, Register out (ptr16 Eq_n) dsOut)
// Called from:
//      fn0800-1E5E
//      fn0800-23EC
byte fn0800-3C99(Eq_n ds, Eq_n dwArg02, Eq_n wArg06, Eq_n wArg08, union Eq_n & bpOut, uint16 & siOut, struct Eq_n & dsOut)
{
	struct Eq_n * ds_n;
	word16 si_n;
	word16 dx_n;
	word16 cx_n;
	Eq_n ds_n;
	word16 si_n;
	Eq_n ds_n;
	word16 si_n;
	mp16 fp;
	Eq_n ss;
	word16 bx_n;
	fn0800-3509(fp - 0x006C, ss, SEQ(ds, 0x4348), out bx_n);
	byte Eq_n::* di_n = fp - 0x006C;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (ss->*di_n != 0x00)
			break;
	}
	memcpy(di_n - 0x01, *((word32) ds + 2644), 0x0D);
	word16 cx_n;
	word16 dx_n;
	word16 si_n;
	Eq_n ds_n;
	fn0800-4234(ds, SEQ(ss, fp - 0x006C), SEQ(ds, 0x0A61), out cx_n, out dx_n, out si_n, out ds_n);
	word16 cx_n;
	fn0800_ACB3(ds_n, dwArg02, 0x00, 0x00, out cx_n);
	struct Eq_n Eq_n::* bp_n = fn0800-3B0A(ds_n, wArg06, wArg08, out si_n, out ds_n);
	Eq_n sp_n;
	sp_n.u0 = <invalid>;
	(ss->*sp_n.u5).t000A.u2 = (uint16) 0x00;
	ui32 ax_dx_n = (ss->*bp_n).t000C.u3 + ((ss->*bp_n).t0008).u0;
	(ss->*sp_n.u5).t0008.u2 = SLICE(ax_dx_n, word16, 16);
	(ss->*sp_n.u5).t0006.u2 = (uint16) (word16) ax_dx_n;
	(ss->*sp_n.u5).t0004.u1.u2 = (ss->*bp_n).t0006.u2;
	(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).t0004.u2;
	word16 cx_n;
	fn0800_ACB3(ds_n, (ss->*sp_n.u5).t0002.u1.u3, (ss->*sp_n.u5).t0006.u3, (ss->*sp_n.u5).t000A.u2, out cx_n);
	(ss->*sp_n.u5).t000A.u2 = (ss->*bp_n).t0006.u2;
	(ss->*sp_n.u5).t0008.u2 = (ss->*bp_n).t0004.u2;
	ui32 dx_ax_n = fn0800-4194(ds_n, (ss->*sp_n.u5).t0008.u3) - (((ss->*bp_n).t000C).u3 + ((ss->*bp_n).t0008).u0);
	(ss->*bp_n).t000E.u2 = SLICE(dx_ax_n, word16, 16);
	Eq_n ax_n = (word16) dx_ax_n;
	(ss->*bp_n).t000C.u2 = (uint16) ax_n;
	(ss->*sp_n.u5).t000A.u2 = (ss->*bp_n).t000E.u2;
	(ss->*sp_n.u5).t0008.u2 = (uint16) ax_n;
	(ss->*sp_n.u5).t0006.u2 = (ss->*bp_n).tFFFFFFFE.u2;
	(ss->*sp_n.u5).t0004.u1.u2 = (ss->*bp_n).tFFFFFFFC.u2;
	(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).t0006.u2;
	(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).t0004.u2;
	struct Eq_n Eq_n::* bp_n = fn0800-3B0A(ds_n, (ss->*sp_n.u5).t0008.u2, (ss->*sp_n.u5).t000A.u2, out si_n, out ds_n);
	Eq_n sp_n;
	sp_n.u0 = <invalid>;
	(ss->*sp_n.u5).t000A.u2 = (ss->*bp_n).tFFFFFFFE.u2;
	(ss->*sp_n.u5).t0008.u2 = (ss->*bp_n).tFFFFFFFC.u2;
	Eq_n ds_n;
	fn0800_A614(ds_n, (ss->*sp_n.u5).t0008.u3, out ds_n);
	Mem280[ss:sp_n + 0x0A:word16] = Mem264[ds_n:10705:word16];
	Mem283[ss:sp_n + 0x08:word16] = Mem280[ds_n:10703:word16];
	Eq_n ds_n;
	fn0800_A614(ds_n, (ss->*sp_n.u5).t0008.u3, out ds_n);
	(ss->*sp_n.u5).t000A.u2 = (uint16) 0x0180;
	(ss->*sp_n.u5).t0008.u2 = (uint16) ds_n;
	(ss->*sp_n.u5).t0006.u2 = (uint16) 0x4348;
	fn0800_A4F6(ds_n, (ss->*sp_n.u5).t000A.u2);
	(ss->*sp_n.u5).t000A.u2 = (uint16) ds_n;
	(ss->*sp_n.u5).t0008.u2 = (uint16) 0x4348;
	fn0800-8F7F(ds_n, (ss->*sp_n.u5).t0008.u3);
	(ss->*sp_n.u5).t000A.u2 = (uint16) ds_n;
	(ss->*sp_n.u5).t0008.u2 = (uint16) 0x4348;
	(ss->*sp_n.u5).t0006.u2 = (uint16) ss;
	(ss->*sp_n.u5).t0004.u1.u2 = (uint16) (bp_n - 0x006A);
	if (fn0800_BA4A(ds_n, (ss->*sp_n.u5).t0004.u1.u3, (ss->*sp_n.u5).t0008.u3) == ~0x00)
	{
		(ss->*sp_n.u5).t000A.u2 = (uint16) ss;
		(ss->*sp_n.u5).t0008.u2 = (uint16) (bp_n - 0x006A);
		(ss->*sp_n.u5).t0006.u2 = (uint16) 0x0A;
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		word16 si_n;
		word16 di_n;
		fn0800-0D24(ds_n, (ss->*sp_n.u5).t0006.u2, (ss->*sp_n.u5).t0008.u3, out cx_n, out dx_n, out bx_n, out si_n, out di_n, out ds_n);
	}
	(ss->*sp_n.u5).t000A.u2 = (uint16) ds_n;
	(ss->*sp_n.u5).t0008.u2 = (uint16) 2661;
	(ss->*sp_n.u5).t0006.u2 = (uint16) ds_n;
	(ss->*sp_n.u5).t0004.u1.u2 = (uint16) 0x4348;
	Eq_n ax_n = fn0800-4234(ds_n, (ss->*sp_n.u5).t0004.u1.u3, (ss->*sp_n.u5).t0008.u3, out cx_n, out dx_n, out si_n, out ds_n);
	ds_n->w29D1 = dx_n;
	ds_n->t29CF = ax_n;
	uint16 si_n = (ss->*sp_n.u5).t000E.u2;
	bpOut.u2 = (ss->*bp_n).t0000.u2;
	siOut = si_n;
	dsOut = ds_n;
	return SLICE(cx_n, byte, 8);
}

// 0800:3DCF: Register word16 fn0800-3DCF(Register Eq_n ds, Stack Eq_n ptrArg02, Register out byte chOut, Register out word16 diOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-3E27
//      fn0800-3F0A
//      fn0800-3FAD
//      fn0800-46FE
//      fn0800-51A9
//      fn0800-741D
//      fn0800-8359
word16 fn0800-3DCF(Eq_n ds, Eq_n ptrArg02, byte & chOut, word16 & diOut, union Eq_n & dsOut)
{
	Eq_n wArg04_n;
	wArg04_n.u3 = SLICE(ptrArg02, word16, 16);
	Eq_n wArg02_n = (word16) ptrArg02;
	Eq_n v11_n = ptrArg02.u5->t0000.u1.u2 - 0x01;
	ptrArg02.u5->t0000.u1.u2 = (uint16) v11_n;
	Eq_n ax_n;
	if (v11_n >= 0x00)
	{
		Eq_n ax_n;
		ax_n.u2 = ptrArg02.u5->t000E.u2;
		union Eq_n Eq_n::* si_n = (union Eq_n Eq_n::*) ptrArg02.u5->t000C.u2;
		ptrArg02.u5->t000C.u2 = (uint16) (ptrArg02.u5->t000C.u2 + 0x01);
		ax_n.u2 = (uint16) (ax_n->*si_n).u0;
	}
	else
	{
		byte ch_n;
		ax_n = fn0800_AEC2(ds, ptrArg02, out ch_n);
	}
	byte ah_n = SLICE(ax_n, byte, 8);
	byte bLoc04_n = (byte) ax_n;
	word16 di;
	if (ax_n == ~0x00)
	{
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		word16 si_n;
		fn0800-0D24(ds, 0x08, fn0800-4271(ds, wArg02_n, wArg04_n), out cx_n, out dx_n, out bx_n, out si_n, out di, out ds);
		ah_n = 0x00;
	}
	chOut = <invalid>;
	diOut = di;
	dsOut = ds;
	return SEQ(ah_n, bLoc04_n);
}

// 0800:3E27: Register uint16 fn0800-3E27(Register Eq_n ds, Stack Eq_n dwArg02, Register out word16 cxOut, Register out word16 diOut, Register out (ptr16 Eq_n) dsOut)
// Called from:
//      fn0800-12E2
//      fn0800-1CF6
//      fn0800-1E5E
//      fn0800-3E5D
//      fn0800-3F58
//      fn0800-4BB1
//      fn0800-5374
//      fn0800-5DCE
//      fn0800-67BF
//      fn0800-7A02
//      fn0800-7C78
uint16 fn0800-3E27(Eq_n ds, Eq_n dwArg02, word16 & cxOut, word16 & diOut, struct Eq_n & dsOut)
{
	struct Eq_n * ds_n;
	word16 di_n;
	byte ch_n;
	Eq_n ds_n;
	word16 di_n;
	byte ch_n;
	Eq_n cx_n;
	cx_n.u0 = <invalid>;
	uint16 ax_n = ((uint16) (byte) fn0800-3DCF(ds, dwArg02, out ch_n, out di_n, out ds_n) << 0x08) + (uint16) ((byte) fn0800-3DCF(ds_n, dwArg02, out ch_n, out di_n, out ds_n));
	cxOut = SEQ(SLICE(cx_n, byte, 8), 0x08);
	diOut = di_n;
	dsOut = ds_n;
	return ax_n;
}

// 0800:3E5D: Sequence uint32 fn0800-3E5D(Register Eq_n ds, Stack Eq_n dwArg02, Register out (ptr16 Eq_n) dsOut)
// Called from:
//      fn0800-1CF6
//      fn0800-24FE
//      fn0800-3992
//      fn0800-4C55
//      fn0800-4F2C
//      fn0800-51A9
//      fn0800-5374
//      fn0800-67BF
//      fn0800-6AD4
//      fn0800-6F20
//      fn0800-741D
uint32 fn0800-3E5D(Eq_n ds, Eq_n dwArg02, struct Eq_n & dsOut)
{
	struct Eq_n * ds_n;
	word16 di_n;
	word16 cx_n;
	Eq_n ds_n;
	word16 di_n;
	word16 cx_n;
	uint32 dx_ax_n = SEQ(fn0800-3E27(ds, dwArg02, out cx_n, out di_n, out ds_n), 0x00) + (uint32) fn0800-3E27(ds_n, dwArg02, out cx_n, out di_n, out ds_n);
	dsOut = ds_n;
	return dx_ax_n;
}

// 0800:3E9A: Register word16 fn0800-3E9A(Register Eq_n ds, Stack Eq_n ptrArg02, Register out Eq_n dsOut)
// Called from:
//      fn0800-51A9
//      fn0800-741D
word16 fn0800-3E9A(Eq_n ds, Eq_n ptrArg02, union Eq_n & dsOut)
{
	word16 cx_n;
	Eq_n wArg04_n;
	wArg04_n.u3 = SLICE(ptrArg02, word16, 16);
	Eq_n wArg02_n = (word16) ptrArg02;
	Eq_n v11_n = ptrArg02.u5->t0000.u1.u2 - 0x01;
	ptrArg02.u5->t0000.u1.u2 = (uint16) v11_n;
	Eq_n ax_n;
	if (v11_n >= 0x00)
	{
		Eq_n ax_n;
		ax_n.u2 = ptrArg02.u5->t000E.u2;
		union Eq_n Eq_n::* si_n = (union Eq_n Eq_n::*) ptrArg02.u5->t000C.u2;
		ptrArg02.u5->t000C.u2 = (uint16) (ptrArg02.u5->t000C.u2 + 0x01);
		ax_n.u2 = (uint16) (ax_n->*si_n).u0;
	}
	else
	{
		byte ch_n;
		ax_n = fn0800_AEC2(ds, ptrArg02, out ch_n);
	}
	byte bLoc04_n = (byte) ax_n;
	if (ax_n == ~0x00)
	{
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		word16 si_n;
		word16 di_n;
		fn0800-0D24(ds, 0x08, fn0800-4271(ds, wArg02_n, wArg04_n), out cx_n, out dx_n, out bx_n, out si_n, out di_n, out ds);
	}
	word16 ax_n = SEQ(SLICE(fn0800_ACB3(ds, ptrArg02, ~0x00, 0x01, out cx_n), byte, 8), bLoc04_n);
	dsOut = ds;
	return ax_n;
}

// 0800:3F0A: Register uint16 fn0800-3F0A(Register Eq_n ds, Stack Eq_n dwArg02, Register out Eq_n dsOut)
// Called from:
//      fn0800-0DE8
//      fn0800-112D
//      fn0800-67BF
uint16 fn0800-3F0A(Eq_n ds, Eq_n dwArg02, union Eq_n & dsOut)
{
	Eq_n ds_n;
	word16 di_n;
	byte ch_n;
	Eq_n ds_n;
	word16 di_n;
	byte ch_n;
	uint16 ax_n = (uint16) (byte) fn0800-3DCF(ds, dwArg02, out ch_n, out di_n, out ds_n);
	uint16 ax_n = (uint16) (byte) fn0800-3DCF(ds_n, dwArg02, out ch_n, out di_n, out ds_n);
	word16 cx_n;
	fn0800_ACB3(ds_n, dwArg02, ~0x01, 0x01, out cx_n);
	dsOut = ds_n;
	return (ax_n << 0x08) + ax_n;
}

// 0800:3F58: Sequence uint32 fn0800-3F58(Register Eq_n ds, Stack Eq_n dwArg02, Register out word16 diOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-0DE8
//      fn0800-112D
//      fn0800-12E2
//      fn0800-46FE
//      fn0800-4F2C
//      fn0800-51A9
//      fn0800-67BF
//      fn0800-6F20
uint32 fn0800-3F58(Eq_n ds, Eq_n dwArg02, word16 & diOut, union Eq_n & dsOut)
{
	Eq_n ds_n;
	word16 di_n;
	word16 cx_n;
	Eq_n ds_n;
	word16 di_n;
	word16 cx_n;
	Eq_n ax_n = fn0800-3E27(ds, dwArg02, out cx_n, out di_n, out ds_n);
	Eq_n ax_n = fn0800-3E27(ds_n, dwArg02, out cx_n, out di_n, out ds_n);
	word16 cx_n;
	fn0800_ACB3(ds_n, dwArg02, ~0x03, 0x01, out cx_n);
	diOut = di_n;
	dsOut = ds_n;
	return SEQ(ax_n, 0x00) + (uint32) ax_n;
}

// 0800:3FAD: Register uint16 fn0800-3FAD(Register Eq_n ds, Stack Eq_n dwArg02, Register out word16 diOut, Register out (ptr16 Eq_n) dsOut)
// Called from:
//      fn0800-46FE
//      fn0800-51A9
//      fn0800-5E64
//      fn0800-741D
uint16 fn0800-3FAD(Eq_n ds, Eq_n dwArg02, word16 & diOut, struct Eq_n & dsOut)
{
	word16 di_n;
	byte ch_n;
	struct Eq_n * ds_n;
	word16 di_n;
	byte ch_n;
	Eq_n ds_n;
	uint16 ax_n = ((uint16) (byte) fn0800-3DCF(ds_n, dwArg02, out ch_n, out di_n, out ds_n) << 0x08) + (uint16) ((byte) fn0800-3DCF(ds, dwArg02, out ch_n, out di_n, out ds_n));
	diOut = di_n;
	dsOut = ds_n;
	return ax_n;
}

// 0800:401E: Register byte fn0800-401E(Register Eq_n ds, Stack Eq_n bArg02, Stack Eq_n dwArg04, Register out word16 cxOut, Register out word16 dxOut, Register out word16 bxOut, Register out (ptr16 Eq_n) dsOut)
// Called from:
//      fn0800-409C
//      fn0800-46FE
//      fn0800-4BB1
//      fn0800-67BF
//      fn0800-741D
//      fn0800-75EA
//      fn0800-831D
byte fn0800-401E(Eq_n ds, Eq_n bArg02, Eq_n dwArg04, word16 & cxOut, word16 & dxOut, word16 & bxOut, struct Eq_n & dsOut)
{
	cu16 wArg02;
	Eq_n bArg02_n = (byte) wArg02;
	word16 cx_n;
	word16 dx_n;
	word16 bx_n;
	word16 di_n;
	Eq_n ds_n;
	fn0800-4047(ds, (byte) (wArg02 >> 0x08), dwArg04, out cx_n, out dx_n, out bx_n, out di_n, out ds_n);
	word16 cx_n;
	word16 dx_n;
	word16 bx_n;
	word16 di_n;
	struct Eq_n * ds_n;
	fn0800-4047(ds_n, bArg02_n, dwArg04, out cx_n, out dx_n, out bx_n, out di_n, out ds_n);
	cxOut = cx_n;
	dxOut = dx_n;
	bxOut = bx_n;
	dsOut = ds_n;
	return 0x00;
}

// 0800:4047: Register byte fn0800-4047(Register Eq_n ds, Stack Eq_n bArg02, Stack Eq_n ptrArg04, Register out word16 cxOut, Register out word16 dxOut, Register out word16 bxOut, Register out Eq_n diOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-401E
//      fn0800-40BF
//      fn0800-46FE
//      fn0800-51A9
//      fn0800-5E64
//      fn0800-67BF
//      fn0800-6F20
//      fn0800-741D
//      fn0800-75EA
//      fn0800-8624
byte fn0800-4047(Eq_n ds, Eq_n bArg02, Eq_n ptrArg04, word16 & cxOut, word16 & dxOut, word16 & bxOut, union Eq_n & diOut, union Eq_n & dsOut)
{
	Eq_n wArg06_n;
	wArg06_n.u3 = SLICE(ptrArg04, word16, 16);
	Eq_n wArg04_n = (word16) ptrArg04;
	Eq_n v11_n = ptrArg04.u5->t0000.u1.u2 + 0x01;
	ptrArg04.u5->t0000.u1.u2 = (uint16) v11_n;
	word16 bx_n = (word16) ptrArg04;
	uint16 ax_n;
	word16 cx_n;
	word16 dx_n;
	if (v11_n < 0x00)
	{
		Eq_n ax_n;
		ax_n.u2 = ptrArg04.u5->t000E.u2;
		union Eq_n Eq_n::* si_n = (union Eq_n Eq_n::*) ptrArg04.u5->t000C.u2;
		ptrArg04.u5->t000C.u2 = (uint16) (ptrArg04.u5->t000C.u2 + 0x01);
		(ax_n->*si_n).u0 = (int8) bArg02;
		ax_n = (uint16) bArg02;
		byte ch;
		cx_n = SEQ(ch, bArg02);
		byte dh;
		dx_n = SEQ(dh, bArg02);
	}
	else
		ax_n = fn0800_B30A(ds, bArg02, ptrArg04, out cx_n, out dx_n, out bx_n);
	Eq_n di;
	if (ax_n == ~0x00)
	{
		word16 si_n;
		ax_n = (uint16) fn0800-0D24(ds, 0x09, fn0800-4271(ds, wArg04_n, wArg06_n), out cx_n, out dx_n, out bx_n, out si_n, out di, out ds);
	}
	cxOut = cx_n;
	dxOut = dx_n;
	bxOut = bx_n;
	diOut = di;
	dsOut = ds;
	return SLICE(ax_n, byte, 8);
}

// 0800:409C: Register Eq_n fn0800-409C(Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n wArg04, Stack Eq_n dwArg06)
// Called from:
//      fn0800-0DE8
//      fn0800-12E2
//      fn0800-46FE
//      fn0800-4BB1
//      fn0800-4C55
//      fn0800-4F2C
//      fn0800-51A9
//      fn0800-67BF
//      fn0800-6AD4
//      fn0800-6F20
//      fn0800-73AC
//      fn0800-741D
//      fn0800-75EA
Eq_n fn0800-409C(Eq_n ds, Eq_n wArg02, Eq_n wArg04, Eq_n dwArg06)
{
	word16 cx_n;
	word16 dx_n;
	word16 bx_n;
	Eq_n ds_n;
	fn0800-401E(ds, (byte) wArg04, dwArg06, out cx_n, out dx_n, out bx_n, out ds_n);
	word16 cx_n;
	word16 dx_n;
	word16 bx_n;
	Eq_n ds_n;
	fn0800-401E(ds_n, (byte) wArg02, dwArg06, out cx_n, out dx_n, out bx_n, out ds_n);
	return ds_n;
}

// 0800:40BF: Register word16 fn0800-40BF(Register Eq_n ds, Stack Eq_n bArg02, Stack Eq_n dwArg04, Register out (ptr16 Eq_n) dsOut)
// Called from:
//      fn0800-46FE
//      fn0800-51A9
//      fn0800-5E64
//      fn0800-741D
word16 fn0800-40BF(Eq_n ds, Eq_n bArg02, Eq_n dwArg04, struct Eq_n & dsOut)
{
	cu16 wArg02;
	bArg02 = (byte) wArg02;
	word16 cx_n;
	word16 dx_n;
	word16 bx_n;
	word16 di_n;
	Eq_n ds_n;
	fn0800-4047(ds, bArg02, dwArg04, out cx_n, out dx_n, out bx_n, out di_n, out ds_n);
	word16 cx_n;
	word16 dx_n;
	word16 bx_n;
	word16 di_n;
	struct Eq_n * ds_n;
	fn0800-4047(ds_n, (byte) (wArg02 >> 0x08), dwArg04, out cx_n, out dx_n, out bx_n, out di_n, out ds_n);
	dsOut = ds_n;
	return di_n;
}

// 0800:4110: Register byte fn0800-4110(Register Eq_n ds, Stack Eq_n dwArg02, Stack Eq_n wArg06, Stack Eq_n wArg08, Stack Eq_n dwArg0A, Register out word16 siOut, Register out word16 diOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-1CF6
//      fn0800-2D0A
//      fn0800-3B0A
//      fn0800-5B15
//      fn0800-7FDC
byte fn0800-4110(Eq_n ds, Eq_n dwArg02, Eq_n wArg06, Eq_n wArg08, Eq_n dwArg0A, word16 & siOut, word16 & diOut, union Eq_n & dsOut)
{
	byte ch_n;
	Eq_n wArg0C;
	wArg0C.u3 = SLICE(dwArg0A, word16, 16);
	Eq_n wArg0A = (word16) dwArg0A;
	Eq_n ax_n = fn0800_ABA3(ds, dwArg02, 0x01, wArg06, dwArg0A, out ch_n);
	Eq_n cx_n;
	cx_n.u0 = <invalid>;
	word16 si;
	word16 di;
	if (wArg08 != 0x00 || ax_n != wArg06)
	{
		word16 dx_n;
		word16 bx_n;
		fn0800-0D24(ds, 0x08, fn0800-4271(ds, wArg0A, wArg0C), out cx_n, out dx_n, out bx_n, out si, out di, out ds);
	}
	siOut = si;
	diOut = di;
	dsOut = ds;
	return SLICE(cx_n, byte, 8);
}

// 0800:4152: Register byte fn0800-4152(Register Eq_n ds, Stack Eq_n dwArg02, Stack Eq_n wArg06, Stack Eq_n wArg08, Stack Eq_n dwArg0A, Register out word16 siOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-12E2
//      fn0800-1E5E
//      fn0800-3B0A
//      fn0800-55E8
//      fn0800-579B
//      fn0800-5D2F
//      fn0800-5E64
//      fn0800-669C
//      fn0800-67BF
//      fn0800-6AD4
//      fn0800-73AC
byte fn0800-4152(Eq_n ds, Eq_n dwArg02, Eq_n wArg06, Eq_n wArg08, Eq_n dwArg0A, word16 & siOut, union Eq_n & dsOut)
{
	Eq_n wArg0C;
	wArg0C.u3 = SLICE(dwArg0A, word16, 16);
	Eq_n wArg0A = (word16) dwArg0A;
	Eq_n ax_n = fn0800_AD85(ds, dwArg02, 0x01, wArg06, dwArg0A);
	word16 si;
	if (wArg08 != 0x00 || ax_n != wArg06)
	{
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		word16 di_n;
		ax_n.u2 = (uint16) fn0800-0D24(ds, 0x09, fn0800-4271(ds, wArg0A, wArg0C), out cx_n, out dx_n, out bx_n, out si, out di_n, out ds);
	}
	siOut = si;
	dsOut = ds;
	return SLICE(ax_n, byte, 8);
}

// 0800:4194: Sequence Eq_n fn0800-4194(Register Eq_n ds, Stack Eq_n dwArg02)
// Called from:
//      fn0800-0DE8
//      fn0800-112D
//      fn0800-12E2
//      fn0800-1CF6
//      fn0800-3992
//      fn0800-3BC3
//      fn0800-3C99
//      fn0800-46FE
//      fn0800-4C55
//      fn0800-51A9
//      fn0800-5B15
//      fn0800-5DCE
Eq_n fn0800-4194(Eq_n ds, Eq_n dwArg02)
{
	Eq_n dx_ax_n = fn0800_AD2F(ds, dwArg02);
	word16 cx_n;
	fn0800_ACB3(ds, dwArg02, 0x00, 0x02, out cx_n);
	Eq_n dx_ax_n = fn0800_AD2F(ds, dwArg02);
	word16 cx_n;
	fn0800_ACB3(ds, dwArg02, dx_ax_n, 0x00, out cx_n);
	return dx_ax_n;
}

// 0800:4234: Register word16 fn0800-4234(Register Eq_n ds, Stack Eq_n dwArg02, Stack Eq_n dwArg06, Register out word16 cxOut, Register out word16 dxOut, Register out word16 siOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-0DE8
//      fn0800-12E2
//      fn0800-19EE
//      fn0800-2DE2
//      fn0800-388C
//      fn0800-3BC3
//      fn0800-3C99
word16 fn0800-4234(Eq_n ds, Eq_n dwArg02, Eq_n dwArg06, word16 & cxOut, word16 & dxOut, word16 & siOut, union Eq_n & dsOut)
{
	Eq_n ds_n;
	word16 cx_n;
	Eq_n dx_ax_n = fn0800_AA7E(ds, dwArg02, dwArg06, out cx_n, out ds_n);
	word16 ax_n = (word16) dx_ax_n;
	word16 dx_n = SLICE(dx_ax_n, word16, 16);
	word16 si;
	if (dx_ax_n == 0x00)
	{
		word16 dx_n;
		word16 bx_n;
		word16 di_n;
		fn0800-0D24(ds_n, 0x07, dwArg02, out cx_n, out dx_n, out bx_n, out si, out di_n, out ds_n);
	}
	cxOut = cx_n;
	dxOut = dx_n;
	siOut = si;
	dsOut = ds_n;
	return ax_n;
}

// 0800:4271: Sequence uipr32 fn0800-4271(Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n wArg04)
// Called from:
//      fn0800-3DCF
//      fn0800-3E9A
//      fn0800-4047
//      fn0800-4110
//      fn0800-4152
uipr32 fn0800-4271(Eq_n ds, Eq_n wArg02, Eq_n wArg04)
{
	if (wArg04 == Mem7[ds:0x29E5:word16] && wArg02 == Mem7[ds:0x29E3:word16])
		return 3405661505;
	if (wArg04 == Mem7[ds:10721:word16] && wArg02 == Mem7[ds:10719:word16])
		return 3405661404;
	if (wArg04 == Mem7[ds:10705:word16] && wArg02 == Mem7[ds:10703:word16])
		return 3405661000;
	if (wArg04 == Mem7[ds:10717:word16] && wArg02 == Mem7[ds:10715:word16])
		return 3405661303;
	if (wArg04 == Mem7[ds:0x29D9:word16] && wArg02 == Mem7[ds:10711:word16])
		return 3405661202;
	if (wArg04 != Mem7[ds:10709:word16] || wArg02 != Mem7[ds:10707:word16])
		return 0xCAFE0A60;
	return 3405661101;
}

// 0800:4311: Register cui16 fn0800-4311(Register Eq_n ds, Stack Eq_n dwArg02, Register out cui16 dxOut, Register out (memptr Eq_n Eq_n) bpOut, Register out word16 siOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-09A3
//      fn0800-1CF6
//      fn0800-2D0A
//      fn0800-3B0A
//      fn0800-5374
//      fn0800-5E64
//      fn0800-75EA
cui16 fn0800-4311(Eq_n ds, Eq_n dwArg02, cui16 & dxOut, struct Eq_n & bpOut, word16 & siOut, union Eq_n & dsOut)
{
	Eq_n ds_n;
	word16 si_n;
	struct Eq_n Eq_n::* bp_n;
	cui16 dx_n;
	cui16 ax_n = fn0800-9F89(ds, dwArg02, out dx_n, out bp_n, out si_n, out ds_n);
	selector ss;
	(ss->*bp_n).wFFFFFFFE = dx_n;
	(ss->*bp_n).wFFFFFFFC = ax_n;
	if ((ax_n | dx_n) == 0x00)
	{
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		word16 di_n;
		fn0800-0D24(ds_n, 0x06, SEQ(ds_n, 2668), out cx_n, out dx_n, out bx_n, out si_n, out di_n, out ds_n);
	}
	cui16 ax_n = (ss->*bp_n).wFFFFFFFC;
	struct Eq_n Eq_n::* bp_n = (ss->*bp_n).ptr0000;
	dxOut = (ss->*bp_n).wFFFFFFFE;
	bpOut = bp_n;
	siOut = si_n;
	dsOut = ds_n;
	return ax_n;
}

// 0800:4346: Register byte fn0800-4346(Register Eq_n ds, Stack Eq_n wArg04, Register out word16 cxOut, Register out word16 dxOut, Register out word16 bxOut, Register out (ptr16 Eq_n) dsOut)
// Called from:
//      fn0800-09A3
//      fn0800-1E5E
//      fn0800-2D0A
//      fn0800-3B0A
//      fn0800-5374
//      fn0800-5E64
//      fn0800-75EA
byte fn0800-4346(Eq_n ds, Eq_n wArg04, word16 & cxOut, word16 & dxOut, word16 & bxOut, struct Eq_n & dsOut)
{
	word16 cx_n;
	word16 dx_n;
	word16 bx_n;
	struct Eq_n * ds_n;
	fn0800-9E75(ds, wArg04, out cx_n, out dx_n, out bx_n, out ds_n);
	cxOut = cx_n;
	dxOut = dx_n;
	bxOut = bx_n;
	dsOut = ds_n;
	return 0x00;
}

// 0800:4357: Register word16 fn0800-4357(Stack Eq_n ptrArg02, Stack (ptr32 int8) ptrArg06)
// Called from:
//      fn0800-29C5
word16 fn0800-4357(Eq_n ptrArg02, int8 * ptrArg06)
{
	while (true)
	{
		word16 wArg02_n = (word16) ptrArg02;
		word16 wArg04_n = SLICE(ptrArg02, word16, 16);
		word16 wArg06_n = (word16) ptrArg06;
		word16 wArg08_n = SLICE(ptrArg06, word16, 16);
		if (*ptrArg06 == 0x00)
			break;
		int8 al_n = *ptrArg06;
		int16 ax_n = (int16) al_n;
		switch (ax_n)
		{
		case 0x2A:
			while (true)
			{
				word16 wArg02_n = (word16) ptrArg02;
				word16 wArg04_n = SLICE(ptrArg02, word16, 16);
				if (*ptrArg02.u3 == 0x2E)
					break;
				Eq_n ptrArg02_n;
				if (*ptrArg02.u3 == 0x00)
				{
					ptrArg02 = ptrArg02_n;
					break;
				}
				ptrArg02_n = SEQ(wArg04_n, wArg02_n + 0x01);
				ptrArg02 = ptrArg02_n;
			}
			break;
		case 0x2E:
			if (*ptrArg02.u3 != 0x00)
			{
l0800_nA7:
				if (al_n != *ptrArg02.u3)
					return 0x00;
				ptrArg02 = SEQ(wArg04_n, wArg02_n + 0x01);
			}
			break;
		default:
			if (ax_n != 0x3F)
				goto l0800_nA7;
			if (*ptrArg02.u3 != 0x2E && *ptrArg02.u3 != 0x00)
				ptrArg02 = SEQ(wArg04_n, wArg02_n + 0x01);
			break;
		}
		ptrArg06 = SEQ(wArg08_n, wArg06_n + 0x01);
	}
	word16 ax_n;
	if (*ptrArg02.u3 == 0x00)
		ax_n = 0x01;
	else
		ax_n = 0x00;
	return ax_n;
}

// 0800:43D4: void fn0800-43D4(Stack (memptr Eq_n Eq_n) wArg02, Stack Eq_n psegArg04, Stack int16 wArg06)
// Called from:
//      fn0800-5A24
//      fn0800-7A02
void fn0800-43D4(struct Eq_n Eq_n::* wArg02, Eq_n psegArg04, int16 wArg06)
{
	int16 cx_n = wArg06;
	struct Eq_n Eq_n::* si_n = (struct Eq_n Eq_n::*) (wArg02 + wArg06);
	while (true)
	{
		si_n -= 0x0C;
		--cx_n;
		if (cx_n == 0x00)
			break;
		(psegArg04->*si_n).w0002 = 0x00;
		(psegArg04->*si_n).w0000 = 0x00;
		(psegArg04->*si_n).w0004 = ~0x00;
		(psegArg04->*si_n).w0008 = 0x00;
		(psegArg04->*si_n).w0006 = 0x00;
		(psegArg04->*si_n).w000A = 0x00;
	}
}

// 0800:441C: void fn0800-441C(Register Eq_n ds, Stack segptr32 ptrArg02, Stack Eq_n wArg06)
// Called from:
//      fn0800-7A02
void fn0800-441C(Eq_n ds, segptr32 ptrArg02, Eq_n wArg06)
{
	struct Eq_n Eq_n::* wArg02 = (word16) ptrArg02;
	struct Eq_n * psegArg04 = SLICE(ptrArg02, selector, 16);
	word16 di_n = 0x00;
	Eq_n cx_n;
	cx_n.u0 = 0x00;
	struct Eq_n Eq_n::* si_n = wArg02;
	Eq_n wLoc04;
	if (wArg06 > 0x00)
	{
		do
		{
			if (((psegArg04->*si_n).w0000 | (psegArg04->*si_n).w0002) != 0x00)
			{
				++di_n;
				wLoc04 = cx_n;
			}
			++si_n;
			cx_n.u3 = &cx_n.u5->b0001;
		} while (cx_n < wArg06);
	}
	Eq_n psegArg04_n;
	psegArg04_n.u3 = SLICE(ptrArg02, selector, 16);
	struct Eq_n Eq_n::* wArg02_n = (word16) ptrArg02;
	if (di_n == 0x00)
		return;
	if (di_n == 0x01)
	{
		struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
		struct Eq_n Eq_n::* bx_n = (word16) ptrArg02 + wLoc04 *s16 0x0C;
		++(es_n->*bx_n).w000A;
	}
	else
	{
		while (fn0800-463B(ds, wArg02_n, psegArg04_n, wArg06) != 0x00)
		{
			Eq_n ax_n = Mem96[ds:18008:word16];
			Eq_n ax_n = Mem145[ds:18010:word16];
			ui32 Eq_n::* bx_n = (ui32 Eq_n::*) (wArg02_n + ax_n);
			ui32 Eq_n::* bx_n = (ui32 Eq_n::*) (wArg02_n + ax_n);
			psegArg04_n->*bx_n += psegArg04_n->*bx_n;
			struct Eq_n Eq_n::* bx_n = (struct Eq_n Eq_n::*) (wArg02_n + ax_n);
			(psegArg04_n->*bx_n).w0002 = 0x00;
			(psegArg04_n->*bx_n).w0000 = 0x00;
			struct Eq_n Eq_n::* bx_n = (struct Eq_n Eq_n::*) (wArg02_n + ax_n);
			++(psegArg04_n->*bx_n).w000A;
			int16 cx_n = ax_n *s16 0x0C;
			int16 dx_n = ax_n *s16 0x0C;
			struct Eq_n Eq_n::* bx_n;
			while (true)
			{
				bx_n = (struct Eq_n Eq_n::*) ((char *) &wArg02_n->w0000 + dx_n);
				if ((psegArg04_n->*bx_n).t0004.u2 == ~0x00)
					break;
				Eq_n ax_n;
				ax_n.u2 = (psegArg04_n->*bx_n).t0004.u2;
				Mem189[ds:18010:word16] = ax_n;
				struct Eq_n Eq_n::* bx_n = (struct Eq_n Eq_n::*) (wArg02_n + ax_n);
				++(psegArg04_n->*bx_n).w000A;
				dx_n = ax_n *s16 0x0C;
			}
			Mem201[psegArg04_n:bx_n + 4:word16] = Mem177[ds:18008:word16];
			struct Eq_n Eq_n::* bx_n = (struct Eq_n Eq_n::*) (wArg02_n + ax_n);
			++(psegArg04_n->*bx_n).w000A;
			while (true)
			{
				struct Eq_n Eq_n::* bx_n = (struct Eq_n Eq_n::*) ((char *) &wArg02_n->w0000 + cx_n);
				if ((psegArg04_n->*bx_n).t0004.u2 == ~0x00)
					break;
				Eq_n ax_n;
				ax_n.u2 = (psegArg04_n->*bx_n).t0004.u2;
				Mem223[ds:18008:word16] = ax_n;
				struct Eq_n Eq_n::* bx_n = (struct Eq_n Eq_n::*) (wArg02_n + ax_n);
				++(psegArg04_n->*bx_n).w000A;
				cx_n = ax_n *s16 0x0C;
			}
		}
		fn0800-4550(wArg02_n, psegArg04_n, wArg06);
	}
}

// 0800:4550: void fn0800-4550(Stack (memptr Eq_n Eq_n) wArg02, Stack Eq_n psegArg04, Stack Eq_n wArg06)
// Called from:
//      fn0800-441C
//      fn0800-5A24
void fn0800-4550(struct Eq_n Eq_n::* wArg02, Eq_n psegArg04, Eq_n wArg06)
{
	word16 dx_n;
	word16 bx_n;
	word16 cx_n;
	mp16 fp;
	struct Eq_n Eq_n::* sp_n = fp - 0x10;
	cup16 wLoc0C_n = 0x01;
	uint32 dwLoc0A_n = 0x80000000;
	uint32 dwLoc06_n = 0x00;
	while (true)
	{
		uint16 wLoc0A_n = (word16) dwLoc0A_n;
		cu16 wLoc08_n = SLICE(dwLoc0A_n, word16, 16);
		if (wLoc0C_n > 0x10)
			break;
		Eq_n di_n;
		di_n.u0 = 0x00;
		struct Eq_n Eq_n::* si_n = wArg02;
		if (wArg06 > 0x00)
		{
			do
			{
				word16 wLoc06_n = (word16) dwLoc06_n;
				Eq_n wLoc04_n;
				wLoc04_n.u3 = SLICE(dwLoc06_n, word16, 16);
				if ((psegArg04->*si_n).w000A == wLoc0C_n)
				{
					struct Eq_n Eq_n::* sp_n = sp_n - 2;
					selector ss;
					(ss->*sp_n).w0000 = wLoc0C_n;
					(ss->*sp_n).wFFFFFFFE = wLoc08_n;
					(ss->*sp_n).wFFFFFFFC = wLoc0A_n;
					(ss->*sp_n).tFFFFFFFA.u2 = (uint16) wLoc04_n;
					(ss->*sp_n).wFFFFFFF8 = wLoc06_n;
					Eq_n dx_ax_n = fn0800-8BC2((ss->*sp_n).tFFFFFFF6.u3, (ss->*sp_n).tFFFFFFFA.u3, out cx_n, out bx_n);
					Eq_n sp_n;
					sp_n.u0 = <invalid>;
					(ss->*((word32) sp_n - 2)).u3 = SLICE(dx_ax_n, word16, 16);
					(ss->*((word32) sp_n - 4)).u2 = (word16) dx_ax_n;
					word16 ax_n = fn0800-45E2(ss->*((word32) sp_n - 4), ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0000.u1.u2, out dx_n);
					(psegArg04->*si_n).w0008 = dx_n;
					(psegArg04->*si_n).w0006 = ax_n;
					sp_n = (struct Eq_n Eq_n::*) &sp_n.u5->t0002.u0;
					dwLoc06_n += dwLoc0A_n;
				}
				++si_n;
				di_n.u3 = &di_n.u5->b0001;
			} while (di_n < wArg06);
		}
		++wLoc0C_n;
		dwLoc0A_n = SEQ(wLoc08_n >> 0x01, __rcr<word16,byte>(wLoc0A_n, 0x01, cond(wLoc08_n >> 0x01) & 0x02));
	}
}

// 0800:45E2: Register ui16 fn0800-45E2(Stack uint16 wArg02, Stack uint16 wArg04, Stack word16 wArg06, Register out uint16 dxOut)
// Called from:
//      fn0800-4550
ui16 fn0800-45E2(uint16 wArg02, uint16 wArg04, word16 wArg06, uint16 & dxOut)
{
	word16 bx_n = wArg06;
	uint16 wLoc04_n = 0x00;
	ui16 wLoc06_n = 0x00;
	while (true)
	{
		--bx_n;
		if (bx_n == 0x00)
			break;
		uint16 ax_n = __rcl<word16,byte>(wLoc04_n, 0x01, cond(wLoc06_n << 0x01) & 0x02);
		wLoc06_n <<= 0x01;
		if ((wArg02 & 0x01) != 0x00)
			wLoc06_n |= 0x01;
		wLoc04_n = ax_n;
		wArg04 >>= 0x01;
		wArg02 = __rcr<word16,byte>(wArg02, 0x01, cond(wArg04 >> 0x01) & 0x02);
	}
	dxOut = wLoc04_n;
	return wLoc06_n;
}

// 0800:463B: Register word16 fn0800-463B(Register Eq_n ds, Stack (memptr Eq_n Eq_n) wArg02, Stack Eq_n psegArg04, Stack Eq_n wArg06)
// Called from:
//      fn0800-441C
word16 fn0800-463B(Eq_n ds, struct Eq_n Eq_n::* wArg02, Eq_n psegArg04, Eq_n wArg06)
{
	word16 wLoc0C_n = ~0x00;
	word16 wLoc0E_n = ~0x00;
	word16 wLoc08_n = ~0x00;
	word16 wLoc0A_n = ~0x00;
	Eq_n cx_n;
	cx_n.u0 = 0x00;
	struct Eq_n Eq_n::* si_n = wArg02;
	up32 dwLoc0A_n = ~0x00;
	up32 dwLoc0E_n = ~0x00;
	if (wArg06 > 0x00)
	{
		do
		{
			cui16 ax_n = (psegArg04->*si_n).w0002;
			cui16 dx_n = (psegArg04->*si_n).w0000;
			if ((dx_n | ax_n) != 0x00)
			{
				if (SEQ(ax_n, dx_n) < dwLoc0A_n)
				{
					Mem81[ds:18008:word16] = Mem78[ds:18010:word16];
					Mem87[ds:18010:word16] = cx_n;
					dwLoc0A_n = SEQ(ax_n, dx_n);
					dwLoc0E_n = dwLoc0A_n;
				}
				else if (SEQ(ax_n, dx_n) < dwLoc0E_n)
				{
					Mem71[ds:18008:word16] = cx_n;
					dwLoc0E_n = SEQ(ax_n, dx_n);
				}
			}
			wLoc0E_n = (word16) dwLoc0E_n;
			wLoc0C_n = SLICE(dwLoc0E_n, word16, 16);
			wLoc0A_n = (word16) dwLoc0A_n;
			wLoc08_n = SLICE(dwLoc0A_n, word16, 16);
			++si_n;
			cx_n.u3 = &cx_n.u5->b0001;
		} while (cx_n < wArg06);
	}
	if ((wLoc08_n != ~0x00 || wLoc0A_n != ~0x00) && (wLoc0C_n != ~0x00 || wLoc0E_n != ~0x00))
		return 0x01;
	return 0x00;
}

// 0800:46FE: Register Eq_n fn0800-46FE(Register Eq_n ds, Register out Eq_n dsOut)
// Called from:
//      fn0800-112D
Eq_n fn0800-46FE(Eq_n ds, union Eq_n & dsOut)
{
	Eq_n ds_n;
	word16 si_n;
	Eq_n ds_n;
	struct Eq_n Eq_n::* bp_n;
	word16 di_n;
	byte ch_n;
	Eq_n ds_n;
	word16 di_n;
	Eq_n ds_n;
	word16 di_n;
	Eq_n ds_n;
	word16 di_n;
	Eq_n ds_n;
	word16 di_n;
	Eq_n ds_n;
	word16 di_n;
	Eq_n ds_n;
	word16 di_n;
	Eq_n ds_n;
	word16 di_n;
	Eq_n ds_n;
	word16 di_n;
	Eq_n ds_n;
	word16 di_n;
	Eq_n ds_n;
	word16 di_n;
	Eq_n ds_n;
	word16 di_n;
	if (Mem15[ds:0x2A03:word32] >=u 0x2A)
	{
		word16 cx_n;
		fn0800_ACB3(ds, Mem34[ds:0x29E3:word32], 0x28, 0x00, out cx_n);
		Eq_n ax_n = fn0800-3FAD(ds, Mem41[ds:0x29E3:word32], out di_n, out ds_n);
		if (Mem59[ds_n:0x2A05:word16] >u 0x00 || Mem59[ds_n:0x2A05:word16] >=u 0x00 && ax_n + 0x24 <=u Mem59[ds_n:0x2A03:word16])
		{
			word16 cx_n;
			fn0800_ACB3(ds_n, Mem95[ds_n:0x29E3:word32], CONVERT(ax_n + 0x20, uint16, uint32), 0x00, out cx_n);
			int32 dx_ax_n = fn0800-8CAA(fn0800-3F58(ds_n, Mem102[ds_n:0x29E3:word32], out di_n, out ds_n), 0x08);
			word16 ax_n = (word16) dx_ax_n;
			if (SLICE(dx_ax_n, word16, 16) != 0x52 || ax_n != 0x4E43)
			{
				dsOut = ds_n;
				return 0x07;
			}
			else
			{
				ui32 dx_ax_n = fn0800_AD2F(ds_n, Mem120[ds_n:0x29E3:word32]);
				word16 cx_n;
				fn0800_ACB3(ds_n, Mem179[ds_n:0x29E3:word32], 0x02, 0x00, out cx_n);
				word16 di_n;
				Eq_n ds_n;
				fn0800-3FAD(ds_n, Mem185[ds_n:0x29E3:word32], out di_n, out ds_n);
				Eq_n ax_n = fn0800-3FAD(ds_n, Mem203[ds_n:0x29E3:word32], out di_n, out ds_n);
				Eq_n wLoc0C_n = ax_n;
				if (di_n != 0x00)
					wLoc0C_n = ax_n - 0x01;
				fn0800-8C69((uint32) wLoc0C_n, 0x09);
				word16 cx_n;
				fn0800_ACB3(ds_n, Mem281[ds_n:0x29E3:word32], 22, 0x00, out cx_n);
				word16 di_n;
				Eq_n ds_n;
				fn0800-3FAD(ds_n, Mem288[ds_n:0x29E3:word32], out di_n, out ds_n);
				word16 ax_n = fn0800-3FAD(ds_n, Mem306[ds_n:0x29E3:word32], out di_n, out ds_n);
				Eq_n ax_n = fn0800-3FAD(ds_n, Mem339[ds_n:0x29E3:word32], out di_n, out ds_n);
				Eq_n ax_n = fn0800-3FAD(ds_n, Mem359[ds_n:0x29E3:word32], out di_n, out ds_n);
				Eq_n ax_n = fn0800-3FAD(ds_n, Mem379[ds_n:0x29E3:word32], out di_n, out ds_n);
				Eq_n ax_n = fn0800-3FAD(ds_n, Mem399[ds_n:0x29E3:word32], out di_n, out ds_n);
				Eq_n ax_n = fn0800-3FAD(ds_n, Mem419[ds_n:0x29E3:word32], out di_n, out ds_n);
				Eq_n ax_n = fn0800-3FAD(ds_n, Mem439[ds_n:0x29E3:word32], out di_n, out ds_n);
				Eq_n ax_n = fn0800-3FAD(ds_n, Mem459[ds_n:0x29E3:word32], out di_n, out ds_n);
				word16 cx_n;
				word16 dx_n;
				word16 bx_n;
				Eq_n ds_n;
				fn0800-401E(ds_n, 0x5A, Mem479[ds_n:10719:word32], out cx_n, out dx_n, out bx_n, out ds_n);
				Eq_n ds_n = fn0800-409C(ds_n, 0x00, 0x00, Mem488[ds_n:10719:word32]);
				Eq_n ds_n = fn0800-409C(ds_n, 0x00, 0x00, Mem514[ds_n:10719:word32]);
				Eq_n ds_n;
				fn0800-40BF(ds_n, (byte) ax_n, Mem540[ds_n:10719:word32], out ds_n);
				Eq_n ds_n;
				fn0800-40BF(ds_n, (byte) ax_n, Mem562[ds_n:10719:word32], out ds_n);
				Eq_n ds_n;
				fn0800-40BF(ds_n, (byte) ax_n, Mem584[ds_n:10719:word32], out ds_n);
				Eq_n ds_n;
				fn0800-40BF(ds_n, (byte) ax_n, Mem606[ds_n:10719:word32], out ds_n);
				word16 cx_n;
				word16 dx_n;
				word16 bx_n;
				Eq_n ds_n;
				fn0800-401E(ds_n, 0x00, Mem628[ds_n:10719:word32], out cx_n, out dx_n, out bx_n, out ds_n);
				Eq_n ds_n;
				fn0800-40BF(ds_n, (byte) ax_n, Mem652[ds_n:10719:word32], out ds_n);
				Eq_n ds_n;
				fn0800-40BF(ds_n, (byte) ax_n, Mem674[ds_n:10719:word32], out ds_n);
				Eq_n ds_n;
				fn0800-40BF(ds_n, 0x1E, Mem696[ds_n:10719:word32], out ds_n);
				Eq_n ds_n;
				fn0800-40BF(ds_n, (byte) ax_n, Mem718[ds_n:10719:word32], out ds_n);
				word16 cx_n;
				word16 dx_n;
				word16 bx_n;
				Eq_n ds_n;
				fn0800-401E(ds_n, 0x00, Mem740[ds_n:10719:word32], out cx_n, out dx_n, out bx_n, out ds_n);
				word16 cx_n;
				fn0800_ACB3(ds_n, Mem789[ds_n:0x29E3:word32], CONVERT(ax_n + 0x20, uint16, uint32), 0x00, out cx_n);
				Eq_n di_n;
				do
				{
					Eq_n ax_n = CONVERT(SLICE(fn0800-3DCF(ds_n, Mem810[ds_n:0x29E3:word32], out ch_n, out di_n, out ds_n), byte, 0), uint8, uint16);
					di_n = ax_n;
					if (ax_n != 0x00)
					{
						Eq_n ax_n = fn0800-3FAD(ds_n, Mem818[ds_n:0x29E3:word32], out di_n, out ds_n);
						word16 si_n = 0x00;
						Eq_n wLoc0C_n = di_n;
						while (true)
						{
							--wLoc0C_n;
							if (wLoc0C_n == 0x00)
								break;
							byte ch_n;
							word16 di_n;
							Eq_n ds_n;
							si_n += CONVERT(SLICE(fn0800-3DCF(ds_n, Mem870[ds_n:0x29E3:word32], out ch_n, out di_n, out ds_n), byte, 0), uint8, uint16);
							Eq_n ds_n;
							fn0800-40BF(ds_n, (byte) si_n, Mem883[ds_n:10719:word32], out ds_n);
							di_n = fn0800-40BF(ds_n, (byte) ax_n, Mem909[ds_n:10719:word32], out ds_n);
						}
					}
				} while (di_n != 0x00);
				cui16 di_n;
				if (fn0800_AD2F(ds_n, Mem956[ds_n:10719:word32]) < 0x0200)
					di_n = 0x0200 - SLICE(fn0800_AD2F(ds_n, Mem964[ds_n:10719:word32]), word16, 0);
				else
					di_n = 0x10 - SLICE(fn0800_AD2F(ds_n, Mem964[ds_n:10719:word32]), word16, 0) & 0x0F;
				while (di_n != 0x00)
				{
					word16 cx_n;
					word16 dx_n;
					word16 bx_n;
					fn0800-4047(ds_n, 0x00, Mem1044[ds_n:10719:word32], out cx_n, out dx_n, out bx_n, out di_n, out ds_n);
				}
				byte cl_n;
				word16 dx_n;
				fn0800-8C8A(fn0800_AD2F(ds_n, Mem1044[ds_n:10719:word32]), 0x04, out cl_n, out dx_n);
				word16 cx_n;
				fn0800_ACB3(ds_n, Mem1114[ds_n:0x29E3:word32], dx_ax_n, 0x00, out cx_n);
				Eq_n ax_n = fn0800-5374(ds_n, out bp_n, out ds_n);
				Eq_n sp_n;
				sp_n.u0 = <invalid>;
				if (ax_n == 0x00)
				{
					selector ss;
					Mem1155[ss:sp_n + -2:word16] = Mem1120[ds_n:10721:word16];
					Mem1158[ss:sp_n + -4:word16] = Mem1155[ds_n:10719:word16];
					Eq_n dx_ax_n = fn0800_AD2F(ds_n, ss->*((word32) sp_n - 4));
					(ss->*bp_n).wFFFFFFFA = SLICE(dx_ax_n, word16, 16);
					(ss->*bp_n).wFFFFFFF8 = (word16) dx_ax_n;
					(ss->*((word32) sp_n - 2)).u0 = 0x00;
					(ss->*((word32) sp_n - 4)).u2 = (ss->*bp_n).tFFFFFFFE.u2;
					(ss->*((word32) sp_n - 6)).u2 = (ss->*bp_n).tFFFFFFFC.u2;
					Mem1185[ss:sp_n + -8:word16] = Mem1182[ds_n:0x29E5:word16];
					Mem1188[ss:sp_n + -0x0A:word16] = Mem1185[ds_n:0x29E3:word16];
					word16 cx_n;
					fn0800_ACB3(ds_n, ss->*((word32) sp_n - 0x0A), ss->*((word32) sp_n - 6), ss->*((word32) sp_n - 2), out cx_n);
					Mem1203[ss:sp_n + -2:word16] = Mem1188[ds_n:0x29E5:word16];
					Mem1206[ss:sp_n + -4:word16] = Mem1203[ds_n:0x29E3:word16];
					ui32 dx_ax_n = fn0800-4194(ds_n, ss->*((word32) sp_n - 4)) - ((ss->*bp_n).tFFFFFFFC).u3;
					(ss->*((word32) sp_n - 2)).u3 = SLICE(dx_ax_n, word16, 16);
					ss->*((word32) sp_n - 4) = (word16) dx_ax_n;
					Mem1229[ss:sp_n + -6:word16] = Mem1226[ds_n:10721:word16];
					Mem1232[ss:sp_n + -8:word16] = Mem1229[ds_n:10719:word16];
					Mem1235[ss:sp_n + -0x0A:word16] = Mem1232[ds_n:0x29E5:word16];
					Mem1238[ss:sp_n + -0x0C:word16] = Mem1235[ds_n:0x29E3:word16];
					struct Eq_n Eq_n::* bp_n = fn0800-3B0A(ds_n, ss->*((word32) sp_n - 4), ss->*((word32) sp_n - 2), out si_n, out ds_n);
					Eq_n di_n;
					di_n.u2 = (ss->*bp_n).tFFFFFFF8.u2;
					(ss->*bp_n).tFFFFFFF6.u2 = (uint16) (word16) fn0800-8CAA((ss->*bp_n).tFFFFFFF8.u3, 0x09);
					Eq_n sp_n;
					sp_n.u0 = <invalid>;
					if ((di_n & 0x01FF) != 0x00)
						(ss->*bp_n).tFFFFFFF6.u2 = (uint16) ((ss->*bp_n).tFFFFFFF6.u2 + 0x01);
					(ss->*sp_n.u5).t000A.u2 = (uint16) 0x00;
					(ss->*sp_n.u5).t0008.u2 = (uint16) 0x00;
					(ss->*sp_n.u5).t0006.u2 = (uint16) 0x02;
					Mem1296[ss:sp_n + 0x04:word16] = Mem1292[ds_n:10721:word16];
					Mem1299[ss:sp_n + 0x02:word16] = Mem1296[ds_n:10719:word16];
					word16 cx_n;
					fn0800_ACB3(ds_n, (ss->*sp_n.u5).t0002.u1.u3, (ss->*sp_n.u5).t0006.u3, (ss->*sp_n.u5).t000A.u2, out cx_n);
					Mem1314[ss:sp_n + 0x0A:word16] = Mem1299[ds_n:10721:word16];
					Mem1317[ss:sp_n + 0x08:word16] = Mem1314[ds_n:10719:word16];
					(ss->*sp_n.u5).t0006.u2 = (uint16) (di_n & 0x01FF);
					Eq_n ds_n;
					fn0800-40BF(ds_n, (ss->*sp_n.u5).t0006.u0, (ss->*sp_n.u5).t0008.u3, out ds_n);
					Mem1336[ss:sp_n + 0x0A:word16] = Mem1320[ds_n:10721:word16];
					Mem1339[ss:sp_n + 0x08:word16] = Mem1336[ds_n:10719:word16];
					(ss->*sp_n.u5).t0006.u2 = (ss->*bp_n).tFFFFFFF6.u2;
					Eq_n ds_n;
					fn0800-40BF(ds_n, (ss->*sp_n.u5).t0006.u0, (ss->*sp_n.u5).t0008.u3, out ds_n);
					Mem1359[ss:sp_n + 0x0A:word16] = Mem1343[ds_n:10721:word16];
					Mem1362[ss:sp_n + 0x08:word16] = Mem1359[ds_n:10719:word16];
					(ss->*sp_n.u5).t0006.u2 = (ss->*bp_n).tFFFFFFF4.u2;
					Eq_n ds_n;
					fn0800-40BF(ds_n, (ss->*sp_n.u5).t0006.u0, (ss->*sp_n.u5).t0008.u3, out ds_n);
					Mem1381[ss:sp_n + 0x0A:word16] = Mem1365[ds_n:10721:word16];
					Mem1384[ss:sp_n + 0x08:word16] = Mem1381[ds_n:10719:word16];
					(ss->*sp_n.u5).t0006.u2 = (ss->*bp_n).tFFFFFFF2.u2;
					Eq_n ds_n;
					fn0800-40BF(ds_n, (ss->*sp_n.u5).t0006.u0, (ss->*sp_n.u5).t0008.u3, out ds_n);
					dsOut = ds_n;
					return 0x00;
				}
				else
				{
					dsOut = ds_n;
					return ax_n;
				}
			}
		}
		else
		{
			dsOut = ds_n;
			return 0x07;
		}
	}
	else
	{
		dsOut = ds;
		return 0x07;
	}
}

// 0800:4B97: Register Eq_n fn0800-4B97(Register Eq_n ds, Register out Eq_n dsOut)
// Called from:
//      fn0800-112D
Eq_n fn0800-4B97(Eq_n ds, union Eq_n & dsOut)
{
	Eq_n ds_n;
	word16 bp_n;
	Eq_n ds_n;
	if (fn0800-5DCE(ds, Mem0[ds:0x29E3:word32], out ds_n) != 0x00)
	{
		Eq_n ax_n = fn0800-5374(ds_n, out bp_n, out ds_n);
		dsOut = ds_n;
		return ax_n;
	}
	else
	{
		dsOut = ds_n;
		return 0x07;
	}
}

// 0800:4BB1: Register Eq_n fn0800-4BB1(Register Eq_n ds, Register out Eq_n dsOut)
// Called from:
//      fn0800-112D
Eq_n fn0800-4BB1(Eq_n ds, union Eq_n & dsOut)
{
	Eq_n ds_n;
	word16 bp_n;
	Eq_n ds_n;
	if (fn0800-5DCE(ds, Mem0[ds:0x29E3:word32], out ds_n) != 0x00)
	{
		word16 cx_n;
		fn0800_ACB3(ds_n, Mem39[ds_n:0x29E3:word32], ~0x11, 0x01, out cx_n);
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		Eq_n ds_n;
		fn0800-401E(ds_n, 0x1A, Mem45[ds_n:10719:word32], out cx_n, out dx_n, out bx_n, out ds_n);
		word16 si_n;
		Eq_n ds_n;
		fn0800-3B0A(ds_n, 0x10, 0x00, out si_n, out ds_n);
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		selector ss;
		Mem117[ss:sp_n + 0x0A:word16] = Mem99[ds_n:10721:word16];
		Mem120[ss:sp_n + 0x08:word16] = Mem117[ds_n:10719:word16];
		(ss->*sp_n.u5).t0006.u2 = (uint16) 0x00;
		(ss->*sp_n.u5).t0004.u1.u2 = (uint16) 0x00;
		Eq_n ds_n = fn0800-409C(ds_n, (ss->*sp_n.u5).t0004.u1.u2, (ss->*sp_n.u5).t0006.u2, (ss->*sp_n.u5).t0008.u3);
		Mem143[ss:sp_n + 0x0A:word16] = Mem128[ds_n:10721:word16];
		Mem146[ss:sp_n + 0x08:word16] = Mem143[ds_n:10719:word16];
		(ss->*sp_n.u5).t0006.u2 = (uint16) 0x00;
		(ss->*sp_n.u5).t0004.u1.u2 = (uint16) 0x00;
		Eq_n ds_n = fn0800-409C(ds_n, (ss->*sp_n.u5).t0004.u1.u2, (ss->*sp_n.u5).t0006.u2, (ss->*sp_n.u5).t0008.u3);
		Mem170[ss:sp_n + 0x0A:word16] = Mem154[ds_n:10721:word16];
		Mem173[ss:sp_n + 0x08:word16] = Mem170[ds_n:10719:word16];
		Mem176[ss:sp_n + 0x06:word16] = Mem173[ds_n:0x29E5:word16];
		Mem179[ss:sp_n + 0x04:word16] = Mem176[ds_n:0x29E3:word16];
		word16 cx_n;
		word16 di_n;
		Eq_n ds_n;
		(ss->*sp_n.u5).t0006.u2 = (uint16) fn0800-3E27(ds_n, (ss->*sp_n.u5).t0004.u1.u3, out cx_n, out di_n, out ds_n);
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		Eq_n ds_n;
		fn0800-401E(ds_n, (ss->*sp_n.u5).t0006.u0, (ss->*sp_n.u5).t0008.u3, out cx_n, out dx_n, out bx_n, out ds_n);
		Eq_n ax_n = fn0800-5374(ds_n, out bp_n, out ds_n);
		dsOut = ds_n;
		return ax_n;
	}
	else
	{
		dsOut = ds_n;
		return 0x07;
	}
}

// 0800:4C55: Register word16 fn0800-4C55(Register Eq_n ds, Register out Eq_n dsOut)
// Called from:
//      fn0800-112D
word16 fn0800-4C55(Eq_n ds, union Eq_n & dsOut)
{
	Eq_n ds_n;
	Eq_n ds_n;
	Eq_n ds_n;
	Eq_n ds_n;
	Eq_n ds_n;
	Eq_n ds_n;
	Eq_n ds_n;
	Eq_n ds_n;
	Eq_n dx_ax_n = fn0800-3E5D(ds, Mem7[ds:0x29E3:word32], out ds_n);
	word16 ax_n = (word16) dx_ax_n;
	if (SLICE(dx_ax_n, word16, 16) != 0x00 || ax_n != 1011)
	{
		dsOut = ds_n;
		return 0x07;
	}
	else
	{
		Eq_n ds_n = fn0800-409C(ds_n, 1011, 0x00, Mem17[ds_n:10719:word32]);
		Eq_n dx_ax_n;
		do
		{
			Eq_n ds_n;
			dx_ax_n = fn0800-3E5D(ds_n, Mem66[ds_n:0x29E3:word32], out ds_n);
			Eq_n ax_n = (word16) dx_ax_n;
			Eq_n dx_n;
			dx_n.u3 = SLICE(dx_ax_n, word16, 16);
			ds_n = fn0800-409C(ds_n, ax_n, dx_n, Mem92[ds_n:10719:word32]);
			Eq_n dwLoc0A_n = dx_ax_n;
			while (true)
			{
				uint16 wLoc0A_n = (word16) dwLoc0A_n;
				ui16 v24_n = SLICE(dwLoc0A_n - 0x01, word16, 16);
				if (dwLoc0A_n == 0x00)
					break;
				Eq_n v43_n = Mem127[ds_n:10721:word16];
				Eq_n v44_n = Mem137[ds_n:10719:word16];
				Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem140[ds_n:0x29E3:word32], out ds_n);
				ds_n = fn0800-409C(ds_n, (word16) dx_ax_n, SLICE(dx_ax_n, word16, 16), SEQ(v43_n, v44_n));
				dwLoc0A_n = SEQ(v24_n, wLoc0A_n - 0x01);
			}
		} while (dx_ax_n != 0x00);
		Eq_n v25_n = Mem127[ds_n:10721:word16];
		Eq_n v26_n = Mem185[ds_n:10719:word16];
		Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem188[ds_n:0x29E3:word32], out ds_n);
		Eq_n ds_n = fn0800-409C(ds_n, (word16) dx_ax_n - 0x01, SLICE(dx_ax_n - 0x01, word16, 16), SEQ(v25_n, v26_n));
		Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem215[ds_n:0x29E3:word32], out ds_n);
		Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem249[ds_n:0x29E3:word32], out ds_n);
		Eq_n ds_n = fn0800-409C(ds_n, (word16) dx_ax_n, SLICE(dx_ax_n, word16, 16), Mem278[ds_n:10719:word32]);
		Eq_n ds_n = fn0800-409C(ds_n, (word16) dx_ax_n - 0x01, SLICE(dx_ax_n - 0x01, word16, 16), Mem290[ds_n:10719:word32]);
		Eq_n dx_ax_n = fn0800_AD2F(ds_n, Mem319[ds_n:10719:word32]);
		Mem349[ds_n:20110:word16] = SLICE(dx_ax_n, word16, 16);
		Mem350[ds_n:20108:word16] = SLICE(dx_ax_n, word16, 0);
		word16 cx_n;
		fn0800_ACB3(ds_n, Mem362[ds_n:0x29E3:word32], 0x04, 0x01, out cx_n);
		Eq_n dwLoc06_n = dx_ax_n - dx_ax_n;
		while (true)
		{
			uint16 wLoc06_n = (word16) dwLoc06_n;
			if (dwLoc06_n == 0x00)
				break;
			Eq_n v54_n = Mem387[ds_n:10721:word16];
			Eq_n v55_n = Mem398[ds_n:10719:word16];
			Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem401[ds_n:0x29E3:word32], out ds_n);
			ds_n = fn0800-409C(ds_n, (word16) dx_ax_n, SLICE(dx_ax_n, word16, 16), SEQ(v54_n, v55_n));
			dwLoc06_n = SEQ(SLICE(dwLoc06_n - 0x01, word16, 16), wLoc06_n - 0x01);
		}
		word16 cx_n;
		fn0800_ACB3(ds_n, Mem455[ds_n:0x29E3:word32], 0x04, 0x01, out cx_n);
		ui32 dx_ax_n = fn0800-3E5D(ds_n, Mem461[ds_n:0x29E3:word32], out ds_n);
		word16 cx_n;
		fn0800_ACB3(ds_n, Mem517[ds_n:0x29E3:word32], fn0800-8C69(SEQ(SLICE(dx_ax_n + 0x01, word16, 16), SLICE(dx_ax_n, word16, 0) + 0x01), 0x02), 0x01, out cx_n);
		Eq_n dx_ax_n = fn0800_AD2F(ds_n, Mem523[ds_n:0x29E3:word32]);
		Eq_n dx_ax_n = fn0800-4194(ds_n, Mem556[ds_n:0x29E3:word32]);
		cup16 ax_n = (word16) dx_ax_n;
		cup16 dx_n = SLICE(dx_ax_n, word16, 16);
		cup16 ax_n = (word16) dx_ax_n;
		cup16 dx_n = SLICE(dx_ax_n, word16, 16);
		if (dx_n >= dx_n && (dx_n != dx_n || ax_n >= ax_n))
		{
			dsOut = ds_n;
			return 0x00;
		}
		else
		{
			Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem562[ds_n:0x29E3:word32], out ds_n);
			Eq_n ax_n = (word16) dx_ax_n;
			Eq_n dx_n;
			dx_n.u3 = SLICE(dx_ax_n, word16, 16);
			Eq_n ds_n = fn0800-409C(ds_n, ax_n, dx_n, Mem618[ds_n:10719:word32]);
			word16 cx_n;
			struct Eq_n seg0800_t::* bx_n = (struct Eq_n seg0800_t::*) seg0800_t::a4F14;
			for (cx_n = 0x04; cx_n != 0x00; --cx_n)
			{
				if ((0x0800->*bx_n).w0000 == ax_n && bx_n[4] == (dx_n & 0x3FFF))
				{
					bx_n[8]();
					dsOut = ds_n;
					word16 ax_n;
					return ax_n;
				}
				++bx_n;
			}
			dsOut = ds_n;
			return 0x09;
		}
	}
}

Eq_n g_a4F14[] = // 0800:4F14
	{
	};
cui16 g_a4F1C[] = // 0800:4F1C
	{
	};
Eq_n g_a4F24[] = // 0800:4F24
	{
	};
// 0800:4F2C: void fn0800-4F2C(Register Eq_n ds)
void fn0800-4F2C(Eq_n ds)
{
	Eq_n wLoc0E_n;
	Eq_n wLoc10_n;
	Eq_n dwLoc18_n;
	selector ds_n;
	word16 si_n;
	Eq_n ds_n;
	Eq_n ds_n;
	word16 sp_n;
	word16 di_n;
	word16 sp_n;
	selector ds_n;
	word16 si_n;
	Eq_n ds_n;
	word16 di_n;
	Eq_n ds_n;
	selector ds_n;
	Eq_n ds_n;
	word32 dwLoc18;
	Eq_n ds_n;
	Eq_n dx_ax_n = fn0800-8C69(fn0800-3E5D(ds, Mem7[ds:0x29E3:word32], out ds_n), 0x02);
	Eq_n dx_n;
	dx_n.u3 = SLICE(dx_ax_n, word16, 16);
	Eq_n ax_n = (word16) dx_ax_n;
	ui32 dx_ax_n = fn0800_AD2F(ds_n, Mem42[ds_n:0x29E3:word32]);
	word32 dwLoc18_n = dwLoc18;
	if (dx_ax_n > 0x12)
	{
		Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem60[ds_n:0x29E3:word32], out ds_n);
		Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem91[ds_n:0x29E3:word32], out ds_n);
		word16 wLoc0E_n = SLICE(dx_ax_n, word16, 16);
		word16 wLoc10_n = (word16) dx_ax_n;
		Eq_n dwLoc18_n = dx_ax_n;
	}
	int32 dx_ax_n = fn0800-8CAA(fn0800-3F58(ds_n, Mem114[ds_n:0x29E3:word32], out di_n, out ds_n), 0x08);
	word16 ax_n = (word16) dx_ax_n;
	selector ss;
	if (SLICE(dx_ax_n, word16, 16) != 0x52 || ax_n != 0x4E43)
	{
		Eq_n v24_n = Mem122[ds_n:10721:word16];
		Eq_n v25_n = Mem157[ds_n:10719:word16];
		int32 dx_ax_n = fn0800-8CAA(dx_ax_n, 0x02);
		Eq_n ds_n = fn0800-409C(ds_n, (word16) dx_ax_n, SLICE(dx_ax_n, word16, 16), SEQ(v24_n, v25_n));
		word16 cx_n;
		fn0800_ACB3(ds_n, Mem202[ds_n:0x29E3:word32], dx_ax_n, 0x00, out cx_n);
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		struct Eq_n Eq_n::* bp_n = fn0800-3B0A(ds_n, ax_n, dx_n, out si_n, out ds_n);
		word16 sp_n = (word16) &sp_n.u5->t000C.u0;
		Eq_n ds_n;
		while (true)
		{
			struct Eq_n Eq_n::* sp_n = sp_n - 2;
			Eq_n ds_n;
			Mem261[ss:sp_n + 0x00:word16] = Mem256[ds_n:0x29E5:word16];
			Mem264[ss:sp_n + -2:word16] = Mem261[ds_n:0x29E3:word16];
			Eq_n dx_ax_n = fn0800-3F58(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out di_n, out ds_n);
			word16 ax_n = (word16) dx_ax_n;
			if (SLICE(dx_ax_n, word16, 16) != 0x00 || ax_n != 1004)
				break;
			(ss->*sp_n).t0000.u2 = (uint16) 0x01;
			(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x00;
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) 0x04;
			Mem317[ss:sp_n + -6:word16] = Mem314[ds_n:0x29E5:word16];
			Mem320[ss:sp_n + -8:word16] = Mem317[ds_n:0x29E3:word16];
			word16 cx_n;
			fn0800_ACB3(ds_n, (ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3, (ss->*sp_n).t0000.u2, out cx_n);
			Mem334[ss:sp_n + 0x00:word16] = Mem320[ds_n:10721:word16];
			Mem337[ss:sp_n + -2:word16] = Mem334[ds_n:10719:word16];
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) 0x00;
			(ss->*sp_n).tFFFFFFFA.u2 = (uint16) 1004;
			Eq_n ds_n = fn0800-409C(ds_n, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3);
			struct Eq_n Eq_n::* sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0000 + 2);
			struct Eq_n Eq_n::* bp_n;
			do
			{
				struct Eq_n Eq_n::* sp_n = sp_n - 2;
				Eq_n ds_n;
				Mem366[ss:sp_n + 0x00:word16] = Mem361[ds_n:0x29E5:word16];
				Mem369[ss:sp_n + -2:word16] = Mem366[ds_n:0x29E3:word16];
				Eq_n dx_ax_n = fn0800-3E5D(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out ds_n);
				struct Eq_n Eq_n::* bp_n;
				(ss->*bp_n).tFFFFFFFC.u2 = SLICE(dx_ax_n, word16, 16);
				Eq_n ax_n = (word16) dx_ax_n;
				(ss->*bp_n).tFFFFFFFA.u2 = (uint16) ax_n;
				Mem388[ss:sp_n + 0x00:word16] = Mem385[ds_n:10721:word16];
				Mem391[ss:sp_n + -2:word16] = Mem388[ds_n:10719:word16];
				(ss->*sp_n).tFFFFFFFC.u2 = (ss->*bp_n).tFFFFFFFC.u2;
				(ss->*sp_n).tFFFFFFFA.u2 = (uint16) ax_n;
				Eq_n ds_n = fn0800-409C(ds_n, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3);
				struct Eq_n Eq_n::* sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0000 + 2);
				if (((ss->*bp_n).tFFFFFFFA.u2 | ((ss->*bp_n).tFFFFFFFC).u2) != 0x00)
				{
					Mem417[ss:sp_n + 0x00:word16] = Mem396[ds_n:0x29E5:word16];
					Mem420[ss:sp_n + -2:word16] = Mem417[ds_n:0x29E3:word16];
					Eq_n dx_ax_n = fn0800-3E5D(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out ds_n);
					(ss->*bp_n).tFFFFFFF8.u2 = SLICE(dx_ax_n - 0x01, word16, 16);
					word16 ax_n = (word16) dx_ax_n;
					(ss->*bp_n).wFFFFFFF6 = ax_n - 0x01;
					Mem442[ss:sp_n + 0x00:word16] = Mem439[ds_n:10721:word16];
					Mem445[ss:sp_n + -2:word16] = Mem442[ds_n:10719:word16];
					(ss->*sp_n).tFFFFFFFC.u2 = (ss->*bp_n).tFFFFFFF8.u2;
					(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (ax_n - 0x01);
					Eq_n ds_n = fn0800-409C(ds_n, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3);
					Eq_n dx_ax_n = fn0800-8C69((ss->*bp_n).tFFFFFFFA.u3, 0x02);
					(ss->*sp_n).t0000.u2 = SLICE(dx_ax_n, word16, 16);
					(ss->*sp_n).tFFFFFFFE.u2 = (uint16) (word16) dx_ax_n;
					Mem482[ss:sp_n + -4:word16] = Mem479[ds_n:10721:word16];
					Mem485[ss:sp_n + -6:word16] = Mem482[ds_n:10719:word16];
					Mem488[ss:sp_n + -8:word16] = Mem485[ds_n:0x29E5:word16];
					Mem491[ss:sp_n + -0x0A:word16] = Mem488[ds_n:0x29E3:word16];
					Eq_n sp_n;
					sp_n.u0 = <invalid>;
					struct Eq_n Eq_n::* bp_n = fn0800-3B0A(ds_n, (ss->*sp_n).tFFFFFFFE.u2, (ss->*sp_n).t0000.u2, out si_n, out ds_n);
					word16 sp_n = (word16) &sp_n.u5->t000C.u0;
				}
			} while (((ss->*bp_n).wFFFFFFFA | (ss->*bp_n).wFFFFFFFC) != 0x00);
		}
		Mem292[ds_n:20108:ui32] = Mem288[ds_n:20108:ui32] + 0x04;
	}
	else
	{
		Eq_n v38_n = Mem122[ds_n:10721:word16];
		Eq_n v39_n = Mem519[ds_n:10719:word16];
		int32 dx_ax_n = fn0800-8CAA(dwLoc18_n, 0x02);
		Eq_n ds_n = fn0800-409C(ds_n, (word16) dx_ax_n, SLICE(dx_ax_n, word16, 16), SEQ(v38_n, v39_n));
		ui32 dx_ax_n = fn0800_AD2F(ds_n, Mem538[ds_n:10719:word32]);
		word16 cx_n;
		fn0800_ACB3(ds_n, Mem581[ds_n:10719:word32], Mem575[ds_n:20108:word32], 0x00, out cx_n);
		Eq_n ds_n = fn0800-409C(ds_n, wLoc10_n, wLoc0E_n, Mem587[ds_n:10719:word32]);
		Mem629[ds_n:20108:ui32] = Mem625[ds_n:20108:ui32] + 0x04;
		word16 cx_n;
		fn0800_ACB3(ds_n, Mem641[ds_n:10719:word32], dx_ax_n, 0x00, out cx_n);
		struct Eq_n Eq_n::* bp_n;
		Eq_n ds_n;
		(ss->*bp_n).tFFFFFFFE.u2 = (uint16) fn0800-5374(ds_n, out bp_n, out ds_n);
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		(ss->*((word32) sp_n - 2)).u0 = 0x00;
		ui32 ax_dx_n = (ss->*bp_n).dwFFFFFFE6 + (ss->*bp_n).dwFFFFFFEE;
		(ss->*((word32) sp_n - 4)).u3 = SLICE(ax_dx_n, word16, 16);
		ss->*((word32) sp_n - 6) = (word16) ax_dx_n;
		Mem691[ss:sp_n + -8:word16] = Mem688[ds_n:0x29E5:word16];
		Mem694[ss:sp_n + -0x0A:word16] = Mem691[ds_n:0x29E3:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, ss->*((word32) sp_n - 0x0A), ss->*((word32) sp_n - 6), ss->*((word32) sp_n - 2), out cx_n);
	}
}

// 0800:518F: Register Eq_n fn0800-518F(Register Eq_n ds, Register out Eq_n dsOut)
// Called from:
//      fn0800-112D
Eq_n fn0800-518F(Eq_n ds, union Eq_n & dsOut)
{
	Eq_n ds_n;
	word16 bp_n;
	Eq_n ds_n;
	if (fn0800-5DCE(ds, Mem0[ds:0x29E3:word32], out ds_n) != 0x00)
	{
		Eq_n ax_n = fn0800-5374(ds_n, out bp_n, out ds_n);
		dsOut = ds_n;
		return ax_n;
	}
	else
	{
		dsOut = ds_n;
		return 0x07;
	}
}

// 0800:51A9: Register Eq_n fn0800-51A9(Register Eq_n ds, Register out Eq_n dsOut)
// Called from:
//      fn0800-112D
Eq_n fn0800-51A9(Eq_n ds, union Eq_n & dsOut)
{
	Eq_n ds_n;
	Eq_n ds_n;
	word16 di_n;
	Eq_n ds_n;
	word16 di_n;
	Eq_n ds_n;
	mp16 fp;
	struct Eq_n Eq_n::* bp_n = fp - 2;
	Eq_n sp_n = fp - 0x08;
	while (true)
	{
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		selector ss;
		Mem20[ss:sp_n + 0x00:word16] = Mem15[ds:0x29E5:word16];
		Mem23[ss:sp_n + -2:word16] = Mem20[ds:0x29E3:word16];
		Eq_n dx_ax_n = fn0800_AD2F(ds, (ss->*sp_n).tFFFFFFFE.u3);
		(ss->*sp_n).t0000.u2 = (uint16) (word16) dx_ax_n;
		(ss->*sp_n).tFFFFFFFE.u2 = SLICE(dx_ax_n, word16, 16);
		Mem41[ss:sp_n + -4:word16] = Mem38[ds:0x29E5:word16];
		Mem44[ss:sp_n + -6:word16] = Mem41[ds:0x29E3:word16];
		Eq_n dx_ax_n = fn0800-4194(ds, (ss->*sp_n).tFFFFFFFA.u3);
		Eq_n ax_n = (word16) dx_ax_n;
		Eq_n dx_n;
		dx_n.u3 = SLICE(dx_ax_n, word16, 16);
		Eq_n bx_n;
		bx_n.u2 = (ss->*sp_n).tFFFFFFFE.u2;
		Eq_n dx_n;
		dx_n.u2 = (ss->*sp_n).t0000.u2;
		if (bx_n >= dx_n && (bx_n != dx_n || dx_n >= ax_n))
			break;
		Mem84[ss:sp_n + 0x00:word16] = Mem44[ds:0x29E5:word16];
		Mem87[ss:sp_n + -2:word16] = Mem84[ds:0x29E3:word16];
		word16 ax_n = fn0800-3E9A(ds, (ss->*sp_n).tFFFFFFFE.u3, out ds);
		if (ax_n != 0x00)
		{
			if (ax_n != 0x01)
			{
				if (ax_n == 0x03)
				{
					word16 si_n;
					for (si_n = 0x00; si_n != 0x03; ++si_n)
					{
						struct Eq_n Eq_n::* sp_n = sp_n - 2;
						Mem509[ss:sp_n + 0x00:word16] = Mem504[ds:10721:word16];
						Mem512[ss:sp_n + -2:word16] = Mem509[ds:10719:word16];
						Mem515[ss:sp_n + -4:word16] = Mem512[ds:0x29E5:word16];
						Mem518[ss:sp_n + -6:word16] = Mem515[ds:0x29E3:word16];
						byte ch_n;
						word16 di_n;
						Eq_n ds_n;
						(ss->*sp_n).tFFFFFFFC.u2 = (uint16) fn0800-3DCF(ds, (ss->*sp_n).tFFFFFFFA.u3, out ch_n, out di_n, out ds_n);
						word16 cx_n;
						word16 dx_n;
						word16 bx_n;
						word16 di_n;
						fn0800-4047(ds_n, (ss->*sp_n).tFFFFFFFC.u0, (ss->*sp_n).tFFFFFFFE.u3, out cx_n, out dx_n, out bx_n, out di_n, out ds);
					}
				}
				else
				{
					Mem419[ss:sp_n + 0x00:word16] = Mem87[ds:0x29E5:word16];
					Mem422[ss:sp_n + -2:word16] = Mem419[ds:0x29E3:word16];
					Eq_n dx_ax_n = fn0800-4194(ds, (ss->*sp_n).tFFFFFFFE.u3);
					(ss->*sp_n).t0000.u2 = (uint16) (word16) dx_ax_n;
					(ss->*sp_n).tFFFFFFFE.u2 = SLICE(dx_ax_n, word16, 16);
					Mem441[ss:sp_n + -4:word16] = Mem438[ds:0x29E5:word16];
					Mem444[ss:sp_n + -6:word16] = Mem441[ds:0x29E3:word16];
					ui32 bx_cx_n = SEQ((ss->*sp_n).tFFFFFFFE.u2, (ss->*sp_n).t0000.u2) - fn0800_AD2F(ds, ((ss->*sp_n).tFFFFFFFA).u3);
					(ss->*sp_n).t0000.u2 = SLICE(bx_cx_n, word16, 16);
					(ss->*sp_n).tFFFFFFFE.u2 = (uint16) (word16) bx_cx_n;
					Mem470[ss:sp_n + -4:word16] = Mem467[ds:10721:word16];
					Mem473[ss:sp_n + -6:word16] = Mem470[ds:10719:word16];
					Mem476[ss:sp_n + -8:word16] = Mem473[ds:0x29E5:word16];
					Mem479[ss:sp_n + -0x0A:word16] = Mem476[ds:0x29E3:word16];
					Eq_n sp_n;
					sp_n.u0 = <invalid>;
					word16 si_n;
					bp_n = fn0800-3B0A(ds, (ss->*sp_n).tFFFFFFFE.u2, (ss->*sp_n).t0000.u2, out si_n, out ds);
					sp_n.u3 = &sp_n.u5->t000C.u0;
				}
				continue;
			}
			Mem150[ss:sp_n + 0x00:word16] = Mem87[ds:10721:word16];
			Mem153[ss:sp_n + -2:word16] = Mem150[ds:10719:word16];
			Mem156[ss:sp_n + -4:word16] = Mem153[ds:0x29E5:word16];
			Mem159[ss:sp_n + -6:word16] = Mem156[ds:0x29E3:word16];
			Eq_n dx_ax_n = fn0800-3E5D(ds, (ss->*sp_n).tFFFFFFFA.u3, out ds_n);
			(ss->*sp_n).tFFFFFFFC.u2 = SLICE(dx_ax_n, word16, 16);
			(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (word16) dx_ax_n;
			Eq_n ds_n = fn0800-409C(ds_n, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3);
			Mem192[ss:sp_n + 0x00:word16] = Mem176[ds_n:0x29E5:word16];
			Mem195[ss:sp_n + -2:word16] = Mem192[ds_n:0x29E3:word16];
			Eq_n ax_n = fn0800-3FAD(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out di_n, out ds_n);
			(ss->*bp_n).tFFFFFFFE.u2 = (uint16) 0x00;
			(ss->*bp_n).tFFFFFFFC.u2 = (uint16) ax_n;
			Mem214[ss:sp_n + 0x00:word16] = Mem211[ds_n:10721:word16];
			Mem217[ss:sp_n + -2:word16] = Mem214[ds_n:10719:word16];
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) ax_n;
			Eq_n ds_n;
			fn0800-40BF(ds_n, (ss->*sp_n).t0004.u0, (ss->*sp_n).tFFFFFFFE.u3, out ds_n);
			Mem235[ss:sp_n + 0x00:word16] = Mem219[ds_n:0x29E5:word16];
			Mem238[ss:sp_n + -2:word16] = Mem235[ds_n:0x29E3:word16];
			int32 dx_ax_n = fn0800-8CAA(fn0800-3F58(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out di_n, out ds_n), 0x08);
			word16 ax_n = (word16) dx_ax_n;
			if (SLICE(dx_ax_n, word16, 16) != 0x52 || ax_n != 0x4E43)
			{
				(ss->*sp_n).t0000.u2 = (ss->*bp_n).tFFFFFFFE.u2;
				(ss->*sp_n).tFFFFFFFE.u2 = (ss->*bp_n).tFFFFFFFC.u2;
				Mem280[ss:sp_n + -4:word16] = Mem276[ds_n:10721:word16];
				Mem283[ss:sp_n + -6:word16] = Mem280[ds_n:10719:word16];
				Mem286[ss:sp_n + -8:word16] = Mem283[ds_n:0x29E5:word16];
				Mem289[ss:sp_n + -0x0A:word16] = Mem286[ds_n:0x29E3:word16];
				Eq_n sp_n;
				sp_n.u0 = <invalid>;
				word16 si_n;
				bp_n = fn0800-3B0A(ds_n, (ss->*sp_n).tFFFFFFFE.u2, (ss->*sp_n).t0000.u2, out si_n, out ds);
				sp_n.u3 = &sp_n.u5->t000C.u0;
				continue;
			}
			Eq_n ax_n = fn0800-5374(ds_n, out bp_n, out ds_n);
			Eq_n sp_n;
			sp_n.u0 = <invalid>;
			if (ax_n == 0x00)
			{
				(ss->*((word32) sp_n - 2)).u0 = 0x01;
				Eq_n dx_n = Mem328[ds_n:0x2A07:word16];
				Mem341[ss:sp_n + -4:word16] = -SLICE(SEQ(Mem328[ds_n:0x2A09:word16], dx_n) + 0x02, word16, 16) - (dx_n != ~0x01);
				ss->*((word32) sp_n - 6) = -((word16) dx_n.u2 + 2);
				Mem346[ss:sp_n + -8:word16] = Mem343[ds_n:10721:word16];
				Mem349[ss:sp_n + -0x0A:word16] = Mem346[ds_n:10719:word16];
				word16 cx_n;
				fn0800_ACB3(ds_n, ss->*((word32) sp_n - 0x0A), ss->*((word32) sp_n - 6), ss->*((word32) sp_n - 2), out cx_n);
				Mem364[ss:sp_n + -2:word16] = Mem349[ds_n:10721:word16];
				Mem367[ss:sp_n + -4:word16] = Mem364[ds_n:10719:word16];
				Mem370[ss:sp_n + -6:word16] = Mem367[ds_n:0x2A07:word16];
				fn0800-40BF(ds_n, (ss->*sp_n.u5).t0006.u0, ss->*((word32) sp_n - 4), out ds);
				(ss->*((word32) sp_n - 2)).u0 = 0x01;
				Mem389[ss:sp_n + -4:word16] = Mem386[ds:0x2A09:word16];
				Mem392[ss:sp_n + -6:word16] = Mem389[ds:0x2A07:word16];
				Mem395[ss:sp_n + -8:word16] = Mem392[ds:10721:word16];
				Mem398[ss:sp_n + -0x0A:word16] = Mem395[ds:10719:word16];
				word16 cx_n;
				fn0800_ACB3(ds, ss->*((word32) sp_n - 0x0A), ss->*((word32) sp_n - 6), ss->*((word32) sp_n - 2), out cx_n);
				sp_n = sp_n;
				continue;
			}
			else
			{
				dsOut = ds_n;
				return ax_n;
			}
		}
		Mem108[ss:sp_n + 0x00:word16] = Mem87[ds:10721:word16];
		Mem111[ss:sp_n + -2:word16] = Mem108[ds:10719:word16];
		Mem114[ss:sp_n + -4:word16] = Mem111[ds:0x29E5:word16];
		Mem117[ss:sp_n + -6:word16] = Mem114[ds:0x29E3:word16];
		byte ch_n;
		word16 di_n;
		Eq_n ds_n;
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) fn0800-3DCF(ds, (ss->*sp_n).tFFFFFFFA.u3, out ch_n, out di_n, out ds_n);
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		word16 di_n;
		fn0800-4047(ds_n, (ss->*sp_n).tFFFFFFFC.u0, (ss->*sp_n).tFFFFFFFE.u3, out cx_n, out dx_n, out bx_n, out di_n, out ds);
		sp_n.u3 = (char *) &sp_n->t0000 + 2;
	}
	dsOut = ds;
	return 0x00;
}

// 0800:5374: Register word16 fn0800-5374(Register Eq_n ds, Register out Eq_n bpOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-112D
//      fn0800-19EE
//      fn0800-46FE
//      fn0800-4B97
//      fn0800-4BB1
//      fn0800-4F2C
//      fn0800-518F
//      fn0800-51A9
word16 fn0800-5374(Eq_n ds, union Eq_n & bpOut, union Eq_n & dsOut)
{
	Eq_n ds_n;
	word16 si_n;
	Eq_n ds_n;
	word16 si_n;
	struct Eq_n Eq_n::* bp_n;
	Eq_n dx_n;
	Eq_n ds_n;
	word16 si_n;
	struct Eq_n Eq_n::* bp_n;
	word16 dx_n;
	Eq_n ds_n;
	Eq_n ds_n;
	fn0800_AD2F(ds, Mem13[ds:0x29E3:word32]);
	Eq_n ds_n;
	Mem56[ds_n:0x2A21:word16] = SLICE(fn0800-3E5D(ds, Mem33[ds:0x29E3:word32], out ds_n), word16, 0) & 0x03;
	Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem56[ds_n:0x29E3:word32], out ds_n);
	Mem75[ds_n:0x2A09:word16] = SLICE(dx_ax_n, word16, 16);
	Eq_n ax_n = (word16) dx_ax_n;
	Mem76[ds_n:0x2A07:word16] = ax_n;
	selector ss;
	if (Mem76[ds_n:0x2A21:word16] != 0x00)
	{
		Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem76[ds_n:0x29E3:word32], out ds_n);
		Mem98[ds_n:0x2A05:word16] = SLICE(dx_ax_n, word16, 16);
		Mem99[ds_n:0x2A03:word16] = SLICE(dx_ax_n, word16, 0);
		Eq_n ds_n;
		word16 cx_n;
		word16 di_n;
		Mem119[ds_n:11851:word16] = fn0800-3E27(ds_n, Mem99[ds_n:0x29E3:word32], out cx_n, out di_n, out ds_n);
		Eq_n ds_n;
		word16 cx_n;
		word16 di_n;
		Mem139[ds_n:11849:word16] = fn0800-3E27(ds_n, Mem119[ds_n:0x29E3:word32], out cx_n, out di_n, out ds_n);
		word16 cx_n;
		word16 di_n;
		Eq_n ds_n;
		fn0800-3E27(ds_n, Mem139[ds_n:0x29E3:word32], out cx_n, out di_n, out ds_n);
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		union Eq_n Eq_n::* bp_n;
		Eq_n ds_n;
		if (fn0800-2D0A(ds_n, out bp_n, out ds_n) == Mem170[ds_n:11849:word16])
		{
			(ss->*sp_n.u5).t0006.u2 = 0x01;
			(ss->*sp_n.u5).t0004.u1.u2 = (uint16) 0x0F;
			Eq_n ax_n = fn0800-4311(ds_n, (ss->*sp_n.u5).t0004.u1.u3, out dx_n, out bp_n, out si_n, out ds_n);
			(ss->*bp_n).wFFFFFFFA = dx_n;
			(ss->*bp_n).tFFFFFFF8.u2 = (uint16) ax_n;
			Mem215[ds_n:11891:word16] = dx_n + 0x01;
			Mem216[ds_n:11889:word16] = 0x00;
			Eq_n sp_n;
			sp_n.u0 = <invalid>;
			(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x01;
			(ss->*sp_n.u5).t0000.u1.u2 = (uint16) 0x0F;
			Eq_n ax_n = fn0800-4311(ds_n, ss->*sp_n.u4, out dx_n, out bp_n, out si_n, out ds_n);
			(ss->*bp_n).tFFFFFFFE.u2 = (uint16) dx_n;
			(ss->*bp_n).tFFFFFFFC.u2 = (uint16) ax_n;
			Mem241[ds_n:11867:word16] = dx_n + 0x01;
			Mem242[ds_n:11865:word16] = 0x00;
			Eq_n dx_n = Mem242[ds_n:11889:word16];
			Mem246[ds_n:11887:word16] = Mem242[ds_n:11891:word16];
			Mem247[ds_n:11885:word16] = dx_n + ~0x02;
			Eq_n dx_n = Mem247[ds_n:11865:word16] + Mem247[ds_n:11825:word16];
			Mem251[ds_n:11863:word16] = Mem247[ds_n:11867:word16];
			Mem252[ds_n:11861:word16] = dx_n;
			Mem253[ds_n:11853:word16] = 0x00;
			Mem258[ds_n:11845:word16] = 0x00;
			Mem259[ds_n:0x29FD:word16] = 0x00;
			Mem260[ds_n:10747:word16] = 0x00;
			Mem261[ds_n:0x2A01:word16] = 0x00;
			Mem262[ds_n:0x29FF:word16] = 0x00;
			Mem264[ss:bp_n + -0x0E:word16] = Mem262[ds_n:11855:word16];
			Eq_n sp_n;
			sp_n.u0 = <invalid>;
			(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x01;
			word16 si_n = 0x00;
			if (fn0800-5C1A(ds_n, (ss->*sp_n.u5).t0002.u1.u2) != 0x00 && (Mem267[ds_n:0x2A25:word16] != 0x02 && Mem267[ds_n:0x2A25:word16] != 0x07))
				si_n = 0x0A;
			word16 si_n = si_n;
			if (si_n == 0x00)
			{
				(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x01;
				if (fn0800-5C1A(ds_n, (ss->*sp_n.u5).t0002.u1.u2) != 0x00)
				{
					if (Mem295[ds_n:0x2A23:word16] != 0x01)
					{
						(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x10;
						Eq_n ax_n = fn0800-5C1A(ds_n, (ss->*sp_n.u5).t0002.u1.u2);
						if (Mem314[ds_n:0x2A25:word16] == 0x02 && Mem314[ds_n:11855:word16] == 0x00)
							Mem327[ds_n:11855:word16] = ax_n;
						if (Mem329[ds_n:11855:word16] != ax_n && Mem329[ds_n:11855:word16] != 0x00)
							si_n = 0x0C;
					}
					if (Mem337[ds_n:11855:word16] == 0x00)
						si_n = 11;
				}
				else
					Mem309[ds_n:11855:word16] = 0x00;
			}
			word16 si_n = si_n;
			if (si_n == 0x00)
			{
				Eq_n ax_n = Mem350[ds_n:0x2A21:word16];
				if (ax_n != 0x01)
				{
					if (ax_n == 0x02)
						si_n = fn0800-579B(ds_n, out ds_n);
				}
				else
					si_n = fn0800-55E8(ds_n, out ds_n);
			}
			Mem395[ds_n:11855:word16] = Mem350[ss:bp_n + -0x0E:word16];
			(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFFA.u2;
			(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).tFFFFFFF8.u2;
			word16 cx_n;
			word16 dx_n;
			word16 bx_n;
			Eq_n ds_n;
			fn0800-4346(ds_n, (ss->*sp_n.u5).t0002.u1.u2, out cx_n, out dx_n, out bx_n, out ds_n);
			(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFFE.u2;
			(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).tFFFFFFFC.u2;
			word16 cx_n;
			word16 dx_n;
			word16 bx_n;
			Eq_n ds_n;
			fn0800-4346(ds_n, (ss->*sp_n.u5).t0002.u1.u2, out cx_n, out dx_n, out bx_n, out ds_n);
			Mem440[ds_n:0x2A03:ui32] = Mem436[ds_n:0x2A03:ui32] + 0x12;
			(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x00;
			ui32 ax_dx_n = Mem443[ss:bp_n + -0x0C:ui32] + Mem443[ds_n:0x2A03:ui32];
			(ss->*sp_n.u5).t0000.u1.u2 = SLICE(ax_dx_n, word16, 16);
			ss->*((word32) sp_n - 2) = (word16) ax_dx_n;
			Mem457[ss:sp_n + -4:word16] = Mem454[ds_n:0x29E5:word16];
			Mem460[ss:sp_n + -6:word16] = Mem457[ds_n:0x29E3:word16];
			word16 cx_n;
			fn0800_ACB3(ds_n, ss->*((word32) sp_n - 6), ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0002.u1.u2, out cx_n);
			if (si_n == 0x00)
			{
				if (Mem460[ds_n:11853:word16] == Mem460[ds_n:11851:word16])
				{
					bpOut.u2 = (ss->*bp_n).t0000.u2;
					dsOut = ds_n;
					return 0x00;
				}
				else
				{
					bpOut.u2 = (ss->*bp_n).t0000.u2;
					dsOut = ds_n;
					return 0x06;
				}
			}
			else
			{
				bpOut.u2 = (ss->*bp_n).t0000.u2;
				dsOut = ds_n;
				return si_n;
			}
		}
		else
		{
			bpOut.u2 = (ss->*bp_n).u2;
			dsOut = ds_n;
			return 0x05;
		}
	}
	else
	{
		struct Eq_n Eq_n::* bp_n = fn0800-3B0A(ds_n, ax_n, Mem76[ds_n:0x2A09:word16], out si_n, out ds_n);
		Eq_n dx_n = Mem520[ds_n:0x2A07:word16];
		Mem538[ds_n:0x2A05:word16] = Mem520[ds_n:0x2A09:word16];
		Mem539[ds_n:0x2A03:word16] = dx_n;
		bpOut.u2 = (ss->*bp_n).t0000.u2;
		dsOut = ds_n;
		return 0x00;
	}
}

// 0800:55E8: Register word16 fn0800-55E8(Register Eq_n ds, Register out (ptr16 Eq_n) dsOut)
// Called from:
//      fn0800-5374
word16 fn0800-55E8(Eq_n ds, struct Eq_n & dsOut)
{
	while (true)
	{
		Eq_n ax_n = Mem12[ds:0x2A01:word16];
		Eq_n dx_n = Mem12[ds:0x29FF:word16];
		if (ax_n >=u Mem12[ds:0x2A09:word16] && (ax_n != Mem12[ds:0x2A09:word16] || dx_n >=u Mem12[ds:0x2A07:word16]))
			break;
		fn0800-5A24(ds, 10511, ds, 0x10);
		fn0800-5A24(ds, 10319, ds, 0x10);
		fn0800-5A24(ds, 10127, ds, 0x10);
		Eq_n dwLoc06_n;
		dwLoc06_n.u0 = (uint32) fn0800-5C39(ds, 0x10);
		while (true)
		{
			uint16 wLoc06_n = (word16) dwLoc06_n;
			ui16 v13_n = SLICE(dwLoc06_n - 0x01, word16, 16);
			if (dwLoc06_n == 0x00)
				break;
			Eq_n ax_n = fn0800-5A8D(ds, 10511, ds);
			Mem183[ds:11847:word16] = ax_n;
			Mem189[ds:0x29FF:ui32] = Mem185[ds:0x29FF:ui32] + CONVERT(ax_n, uint16, uint32);
			if (Mem189[ds:11847:word16] != 0x00)
			{
				while (true)
				{
					Eq_n ax_n = Mem193[ds:11847:word16];
					Mem196[ds:11847:word16] = Mem193[ds:11847:word16] - 0x01;
					if (ax_n == 0x00)
						break;
					Eq_n ds_n;
					word16 si_n;
					word16 di_n;
					ds = fn0800-5D2F(ds_n, fn0800-5B15(ds, out si_n, out di_n, out ds_n) ^ Mem196[ds_n:11855:byte]);
				}
				if ((Mem196[ds:11855:word16] & 0x01) != 0x00)
					Mem252[ds:11855:word16] = Mem196[ds:11855:word16] >>u 0x01 | 0x8000;
				else
					Mem244[ds:11855:word16] = Mem196[ds:11855:word16] >>u 0x01;
				Eq_n es_bx_n = Mem254[ds:11885:segptr32];
				uint32 ax_dx_n = fn0800-8C69(SEQ((uint16) es_bx_n.u5->t0002.u0, 0x00) + (uint32) ((uint16) (es_bx_n.u5)->b0001 << 0x08) + (uint32) (*es_bx_n.u3), Mem284[ds:11845:byte]) + CONVERT(Mem316[ds:10747:word16] & (0x01 << Mem310[ds:11845:byte]) - 0x01, uint16, uint32);
				Mem333[ds:0x29FD:word16] = SLICE(ax_dx_n, word16, 16);
				Mem334[ds:10747:word16] = SLICE(ax_dx_n, word16, 0);
			}
			if ((wLoc06_n - 0x01 | v13_n) == 0x00)
				break;
			Mem366[ds:11819:word16] = fn0800-5A8D(ds, 10319, ds) + 0x01;
			Eq_n ax_n = fn0800-5A8D(ds, 10127, ds);
			Mem383[ds:11817:word16] = ax_n + 0x02;
			Mem389[ds:0x29FF:ui32] = Mem385[ds:0x29FF:ui32] + CONVERT(ax_n + 0x02, uint16, uint32);
			while (true)
			{
				Eq_n ax_n = Mem392[ds:11817:word16];
				Mem395[ds:11817:word16] = Mem392[ds:11817:word16] - 0x01;
				dwLoc06_n = SEQ(v13_n, wLoc06_n - 0x01);
				if (ax_n == 0x00)
					break;
				Eq_n es_bx_n = Mem395[ds:11861:segptr32];
				ds = fn0800-5D2F(ds, Mem395[SLICE(es_bx_n, selector, 16):SLICE(es_bx_n, word16, 0) - Mem395[ds:11819:word16]:byte]);
			}
		}
	}
	int32 dx_ax_n = CONVERT(Mem31[ds:11861:word16] - Mem31[ds:11865:word16] - Mem31[ds:11825:word16], word16, uint32);
	word16 si_n;
	struct Eq_n * ds_n;
	fn0800-4152(ds, SEQ(Mem45[ds:11867:word16], Mem45[ds:11865:word16] + Mem45[ds:11825:word16]), SLICE(dx_ax_n, word16, 0), 0x00, Mem12[ds:10719:word32], out si_n, out ds_n);
	dsOut = ds_n;
	return 0x00;
}

// 0800:579B: Register word16 fn0800-579B(Register Eq_n ds, Register out (ptr16 Eq_n) dsOut)
// Called from:
//      fn0800-5374
word16 fn0800-579B(Eq_n ds, struct Eq_n & dsOut)
{
	while (true)
	{
		Eq_n ax_n = Mem5[ds:0x2A01:word16];
		Eq_n dx_n = Mem5[ds:0x29FF:word16];
		if (ax_n >=u Mem5[ds:0x2A09:word16] && (ax_n != Mem5[ds:0x2A09:word16] || dx_n >=u Mem5[ds:0x2A07:word16]))
		{
			ui32 dx_ax_n = CONVERT(Mem24[ds:11861:word16] - Mem24[ds:11865:word16] - Mem24[ds:11825:word16], word16, uint32);
			word16 si_n;
			struct Eq_n * ds_n;
			fn0800-4152(ds, SEQ(Mem38[ds:11867:word16], Mem38[ds:11865:word16] + Mem38[ds:11825:word16]), SLICE(dx_ax_n, word16, 0), 0x00, Mem5[ds:10719:word32], out si_n, out ds_n);
			dsOut = ds_n;
			return 0x00;
		}
l0800_nCF:
		while (true)
		{
			while (fn0800-5CD9(ds, 0x01) == 0x00)
			{
				Eq_n ds_n;
				word16 si_n;
				word16 di_n;
				ds = fn0800-5D2F(ds_n, fn0800-5B15(ds, out si_n, out di_n, out ds_n) ^ Mem68[ds_n:11855:byte]);
				if ((Mem102[ds:11855:word16] & 0x01) != 0x00)
					Mem129[ds:11855:word16] = Mem102[ds:11855:word16] >>u 0x01 | 0x8000;
				else
					Mem121[ds:11855:word16] = Mem102[ds:11855:word16] >>u 0x01;
				Mem137[ds:0x29FF:ui32] = Mem133[ds:0x29FF:ui32] + 0x01;
			}
			if (fn0800-5CD9(ds, 0x01) != 0x00)
				break;
			fn0800-593F(ds);
			if (Mem141[ds:11817:word16] == 0x09)
			{
				fn0800-5A0F(ds);
				Mem230[ds:0x29FF:ui32] = Mem226[ds:0x29FF:ui32] + CONVERT(Mem141[ds:11847:word16], uint16, uint32);
				while (true)
				{
					Eq_n ax_n = Mem233[ds:11847:word16];
					Mem236[ds:11847:word16] = Mem233[ds:11847:word16] - 0x01;
					if (ax_n == 0x00)
						break;
					Eq_n ds_n;
					word16 si_n;
					word16 di_n;
					ds = fn0800-5D2F(ds_n, fn0800-5B15(ds, out si_n, out di_n, out ds_n) ^ Mem236[ds_n:11855:byte]);
				}
				if ((Mem236[ds:11855:word16] & 0x01) != 0x00)
					Mem292[ds:11855:word16] = Mem236[ds:11855:word16] >>u 0x01 | 0x8000;
				else
					Mem284[ds:11855:word16] = Mem236[ds:11855:word16] >>u 0x01;
			}
			else
			{
				ds = fn0800-5975(ds);
				Mem180[ds:0x29FF:ui32] = Mem176[ds:0x29FF:ui32] + CONVERT(Mem141[ds:11817:word16], uint16, uint32);
				while (true)
				{
					Eq_n ax_n = Mem183[ds:11817:word16];
					Mem186[ds:11817:word16] = Mem183[ds:11817:word16] - 0x01;
					if (ax_n == 0x00)
						break;
					Eq_n es_bx_n = Mem186[ds:11861:segptr32];
					ds = fn0800-5D2F(ds, Mem186[SLICE(es_bx_n, selector, 16):SLICE(es_bx_n, word16, 0) - Mem186[ds:11819:word16]:byte]);
				}
			}
		}
		if (fn0800-5CD9(ds, 0x01) == 0x00)
			break;
		if (fn0800-5CD9(ds, 0x01) == 0x00)
		{
			Mem353[ds:11817:word16] = 0x03;
l0800_n:
			ds = fn0800-5975(ds);
			goto l0800_n;
		}
		word16 si_n;
		word16 di_n;
		Mem339[ds:11817:word16] = CONVERT(fn0800-5B15(ds, out si_n, out di_n, out ds), uint8, uint16) + 0x08;
		if (Mem339[ds:11817:word16] != 0x08)
			goto l0800_n;
		fn0800-5CD9(ds, 0x01);
	}
	Mem368[ds:11817:word16] = 0x02;
	word16 si_n;
	word16 di_n;
	Mem386[ds:11819:word16] = CONVERT(fn0800-5B15(ds, out si_n, out di_n, out ds), uint8, uint16) + 0x01;
l0800_n:
	Mem396[ds:0x29FF:ui32] = Mem392[ds:0x29FF:ui32] + CONVERT(Mem388[ds:11817:word16], uint16, uint32);
	while (true)
	{
		Eq_n ax_n = Mem399[ds:11817:word16];
		Mem402[ds:11817:word16] = Mem399[ds:11817:word16] - 0x01;
		if (ax_n == 0x00)
			break;
		Eq_n es_bx_n = Mem402[ds:11861:segptr32];
		ds = fn0800-5D2F(ds, Mem402[SLICE(es_bx_n, selector, 16):SLICE(es_bx_n, word16, 0) - Mem402[ds:11819:word16]:byte]);
	}
	goto l0800_nCF;
}

// 0800:593F: void fn0800-593F(Register Eq_n ds)
// Called from:
//      fn0800-579B
void fn0800-593F(Eq_n ds)
{
	Mem18[ds:11817:word16] = fn0800-5CD9(ds, 0x01) + 0x04;
	if (fn0800-5CD9(ds, 0x01) != 0x00)
		Mem49[ds:11817:word16] = (Mem36[ds:11817:word16] - 0x01 << 0x01) + fn0800-5CD9(ds, 0x01);
}

// 0800:5975: Register Eq_n fn0800-5975(Register Eq_n ds)
// Called from:
//      fn0800-579B
Eq_n fn0800-5975(Eq_n ds)
{
	Mem5[ds:11819:word16] = 0x00;
	if (fn0800-5CD9(ds, 0x01) != 0x00)
	{
		Mem33[ds:11819:word16] = fn0800-5CD9(ds, 0x01);
		if (fn0800-5CD9(ds, 0x01) != 0x00)
		{
			Mem81[ds:11819:word16] = (Mem66[ds:11819:word16] << 0x01) + fn0800-5CD9(ds, 0x01) | 0x04;
			if (fn0800-5CD9(ds, 0x01) == 0x00)
				Mem111[ds:11819:word16] = (Mem99[ds:11819:word16] << 0x01) + fn0800-5CD9(ds, 0x01);
		}
		else if (Mem36[ds:11819:word16] == 0x00)
			Mem63[ds:11819:word16] = fn0800-5CD9(ds, 0x01) + 0x02;
	}
	Eq_n ds_n;
	word16 si_n;
	word16 di_n;
	Mem137[ds_n:11819:word16] = (Mem127[ds_n:11819:word16] << 0x08) + CONVERT(fn0800-5B15(ds, out si_n, out di_n, out ds_n), uint8, uint16) + 0x01;
	return ds_n;
}

// 0800:5A0F: void fn0800-5A0F(Register Eq_n ds)
// Called from:
//      fn0800-579B
void fn0800-5A0F(Eq_n ds)
{
	Mem20[ds:11847:word16] = (fn0800-5CD9(ds, 0x04) << 0x02) + 0x0C;
}

// 0800:5A24: void fn0800-5A24(Register Eq_n ds, Stack (memptr Eq_n Eq_n) wArg02, Stack Eq_n wArg04, Stack int16 wArg06)
// Called from:
//      fn0800-55E8
void fn0800-5A24(Eq_n ds, struct Eq_n Eq_n::* wArg02, Eq_n wArg04, int16 wArg06)
{
	fn0800-43D4(wArg02, wArg04, wArg06);
	Eq_n ax_n = fn0800-5C39(ds, 0x05);
	Eq_n wArg06_n = ax_n;
	if (ax_n != 0x00)
	{
		if (ax_n > 0x10)
			wArg06_n.u0 = 0x10;
		Eq_n di_n;
		di_n.u0 = 0x00;
		struct Eq_n Eq_n::* si_n = (struct Eq_n Eq_n::*) &wArg02->w000A;
		if (wArg06_n > 0x00)
		{
			do
			{
				(wArg04->*si_n).w0000 = (word16) fn0800-5C39(ds, 0x04);
				++si_n;
				di_n.u3 = &di_n.u5->b0001;
			} while (di_n < wArg06_n);
		}
		fn0800-4550(wArg02, wArg04, wArg06_n);
	}
}

// 0800:5A8D: Register Eq_n fn0800-5A8D(Register Eq_n ds, Stack (memptr Eq_n Eq_n) wArg02, Stack Eq_n psegArg04)
// Called from:
//      fn0800-55E8
Eq_n fn0800-5A8D(Eq_n ds, struct Eq_n Eq_n::* wArg02, Eq_n psegArg04)
{
	Eq_n wLoc04_n;
	wLoc04_n.u0 = 0x00;
	struct Eq_n Eq_n::* di_n = wArg02;
	while (true)
	{
		byte bLoc04_n = (byte) wLoc04_n;
		if ((psegArg04->*di_n).t000A.u1 != 0x00)
		{
			cui16 cx_n = Mem21[ds:10747:word16] & (0x01 << Mem21[psegArg04:di_n + 0x0A:byte]) - 0x01;
			if ((psegArg04->*di_n).w0008 == 0x00 && cx_n == (psegArg04->*di_n).w0006)
			{
				fn0800-5C39(ds, (psegArg04->*(wArg02 + wLoc04_n)).t000A.u1);
				if (wLoc04_n >= 0x02)
					return fn0800-5C39(ds, wLoc04_n - 0x01) | 0x01 << bLoc04_n - 0x01;
				return wLoc04_n;
			}
		}
		++di_n;
		wLoc04_n = (word16) wLoc04_n + 1;
	}
}

// 0800:5B15: Register uint8 fn0800-5B15(Register Eq_n ds, Register out ui16 siOut, Register out word16 diOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-55E8
//      fn0800-579B
//      fn0800-5975
//      fn0800-5C39
//      fn0800-5CD9
uint8 fn0800-5B15(Eq_n ds, ui16 & siOut, word16 & diOut, union Eq_n & dsOut)
{
	Eq_n dx_n = Mem7[ds:11889:word16];
	ui16 si;
	word16 di;
	if (Mem7[ds:11891:word16] != Mem7[ds:11887:word16] || dx_n + ~0x02 != Mem7[ds:11885:word16])
	{
l0800_nC0B:
		Eq_n es_bx_n = Mem222[ds:11885:segptr32];
		Mem225[ds:11885:word16] = Mem222[ds:11885:word16] + 0x01;
		uint8 al_n = (uint8) *es_bx_n.u3;
		siOut = si;
		diOut = di;
		dsOut = ds;
		return al_n;
	}
	uint32 bx_cx_n = fn0800-4194(ds, Mem7[ds:0x29E3:word32]) - fn0800_AD2F(ds, Mem39[ds:0x29E3:word32]);
	uint32 dx_ax_n;
	if (bx_cx_n > 0xFFFD)
		dx_ax_n = 0xFFFD;
	else
		dx_ax_n = bx_cx_n;
	Eq_n v26_n = Mem88[ds:0x29E5:word16];
	Eq_n v27_n = Mem97[ds:0x29E3:word16];
	Eq_n ax_n = Mem105[ds:11891:word16];
	Eq_n dx_n = Mem105[ds:11889:word16];
	Mem108[ds:11887:word16] = ax_n;
	Mem109[ds:11885:word16] = dx_n;
	Eq_n ax_n = (word16) dx_ax_n;
	word16 si_n;
	word16 di_n;
	Eq_n ds_n;
	fn0800-4110(ds, SEQ(ax_n, dx_n), ax_n, SLICE(dx_ax_n, word16, 16), SEQ(v26_n, v27_n), out si_n, out di_n, out ds_n);
	uint32 v30_v29_n = bx_cx_n - dx_ax_n;
	cup16 v29_n = (word16) v30_v29_n;
	cup16 v30_n = SLICE(v30_v29_n, word16, 16);
	uint32 dwLoc06_n = v30_v29_n;
	if (true)
	{
		if (v30_n > 0x00)
		{
l0800_nBC1:
			dwLoc06_n = 0x02;
			goto l0800_nBCB;
		}
		dwLoc06_n = v30_v29_n;
		if (v29_n > 0x02)
			goto l0800_nBC1;
	}
l0800_nBCB:
	fn0800-4110(ds_n, SEQ(Mem167[ds_n:11891:word16], Mem167[ds_n:11889:word16] + ax_n), SLICE(dwLoc06_n, word16, 0), SLICE(dwLoc06_n, word16, 16), Mem151[ds_n:0x29E3:word32], out si, out di, out ds);
	word16 cx_n;
	fn0800_ACB3(ds, Mem202[ds:0x29E3:word32], -dwLoc06_n, 0x01, out cx_n);
	goto l0800_nC0B;
}

// 0800:5C1A: Register Eq_n fn0800-5C1A(Register Eq_n ds, Stack Eq_n wArg02)
// Called from:
//      fn0800-5374
Eq_n fn0800-5C1A(Eq_n ds, Eq_n wArg02)
{
	if (Mem7[ds:0x2A21:word16] != 0x02)
		return fn0800-5C39(ds, wArg02);
	return fn0800-5CD9(ds, wArg02);
}

// 0800:5C39: Register cui16 fn0800-5C39(Register Eq_n ds, Stack Eq_n wArg02)
// Called from:
//      fn0800-55E8
//      fn0800-5A24
//      fn0800-5A8D
//      fn0800-5C1A
cui16 fn0800-5C39(Eq_n ds, Eq_n wArg02)
{
	word16 di_n;
	word16 si_n;
	selector ds_n;
	Eq_n ds_n;
	Eq_n si_n = wArg02;
	cui16 di_n = 0x00;
	ui16 wLoc08_n = 0x01;
	while (true)
	{
		Eq_n si_n = si_n;
		if (si_n == 0x00)
			break;
		if (Mem32[ds:11845:word16] == 0x00)
		{
			uint32 dx_ax_n = fn0800-8C69(CONVERT(Mem74[Mem74[ds_n:11885:segptr32] + 1:byte], uint8, uint32), 0x18) + SEQ(CONVERT(Mem74[Mem74[ds_n:11885:segptr32] + 0x00:byte], uint8, uint16), 0x00) + CONVERT(CONVERT(fn0800-5B15(ds_n, out si_n, out di_n, out ds_n), uint8, uint16) << 0x08, uint16, uint32) + CONVERT(fn0800-5B15(ds, out si_n, out di_n, out ds_n), uint8, uint32);
			Mem117[ds_n:0x29FD:word16] = SLICE(dx_ax_n, word16, 16);
			Mem118[ds_n:10747:word16] = SLICE(dx_ax_n, word16, 0);
			Mem119[ds_n:11845:word16] = 0x10;
			ds = ds_n;
		}
		if ((Mem121[ds:10747:word16] & 0x01) != 0x00)
			di_n |= wLoc08_n;
		uint16 ax_n = Mem121[ds:0x29FD:word16];
		uint16 dx_n = __rcr<word16,byte>(Mem121[ds:10747:word16], 0x01, cond(ax_n >>u 0x01) & 0x02);
		Mem145[ds:0x29FD:word16] = ax_n >>u 0x01;
		Mem146[ds:10747:word16] = dx_n;
		Mem153[ds:11845:word16] = Mem150[ds:11845:word16] - 0x01;
		wLoc08_n <<= 0x01;
		si_n = si_n - 0x01;
	}
	return di_n;
}

// 0800:5CD9: Register ui16 fn0800-5CD9(Register Eq_n ds, Stack Eq_n wArg02)
// Called from:
//      fn0800-579B
//      fn0800-593F
//      fn0800-5975
//      fn0800-5A0F
//      fn0800-5C1A
ui16 fn0800-5CD9(Eq_n ds, Eq_n wArg02)
{
	Eq_n di_n = wArg02;
	ui16 si_n = 0x00;
	while (true)
	{
		Eq_n di_n = di_n;
		if (di_n == 0x00)
			break;
		if (Mem27[ds:11845:word16] == 0x00)
		{
			uint8 al_n = fn0800-5B15(ds, out si_n, out di_n, out ds);
			Mem44[ds:0x29FD:word16] = 0x00;
			Mem47[ds:10747:word16] = CONVERT(al_n, uint8, uint16);
			Mem48[ds:11845:word16] = 0x08;
		}
		si_n <<= 0x01;
		if ((Mem53[ds:10747:word16] & 0x80) != 0x00)
			++si_n;
		uint16 dx_n = Mem53[ds:10747:word16];
		Mem73[ds:0x29FD:word16] = __rcl<word16,byte>(Mem53[ds:0x29FD:word16], 0x01, cond(dx_n << 0x01) & 0x02);
		Mem74[ds:10747:word16] = dx_n << 0x01;
		Mem76[ds:11845:word16] = Mem74[ds:11845:word16] - 0x01;
		di_n = di_n - 0x01;
	}
	return si_n;
}

// 0800:5D2F: Register Eq_n fn0800-5D2F(Register Eq_n ds, Stack ui8 bArg02)
// Called from:
//      fn0800-55E8
//      fn0800-579B
Eq_n fn0800-5D2F(Eq_n ds, ui8 bArg02)
{
	Eq_n dx_n = Mem7[ds:11865:word16];
	if (Mem7[ds:11867:word16] == Mem7[ds:11863:word16] && dx_n - 0x01 == Mem7[ds:11861:word16])
	{
		ui32 ax_dx_n = 0xFFFF - CONVERT(Mem22[ds:11825:word16], uint16, uint32);
		word16 si_n;
		fn0800-4152(ds, SEQ(Mem32[ds:11867:word16], Mem32[ds:11865:word16] + Mem32[ds:11825:word16]), SLICE(ax_dx_n, word16, 0), SLICE(ax_dx_n, word16, 16), Mem7[ds:10719:word32], out si_n, out ds);
		fn0800_B0F3(Mem64[ds:11865:word32], SEQ(Mem56[ds:11863:word16], Mem56[ds:11861:word16] - Mem56[ds:11825:word16]), Mem40[ds:11825:word16]);
		Eq_n dx_n = Mem70[ds:11865:word16] + Mem70[ds:11825:word16];
		Mem87[ds:11863:word16] = Mem70[ds:11867:word16];
		Mem88[ds:11861:word16] = dx_n;
	}
	Mem97[Mem90[ds:11861:segptr32] + 0x00:byte] = bArg02;
	Mem99[ds:11861:word16] = Mem97[ds:11861:word16] + 0x01;
	Mem115[ds:11853:word16] = ds:0x2A29[(CONVERT(Mem99[ds:11853:byte] ^ bArg02, uint8, uint16) & 0xFF) * 0x02] ^ Mem99[ds:11853:word16] >>u 0x08;
	return ds;
}

// 0800:5DCE: Register cui16 fn0800-5DCE(Register Eq_n ds, Stack Eq_n dwArg02, Register out Eq_n dsOut)
// Called from:
//      fn0800-4B97
//      fn0800-4BB1
//      fn0800-518F
cui16 fn0800-5DCE(Eq_n ds, Eq_n dwArg02, union Eq_n & dsOut)
{
	Eq_n dx_ax_n = fn0800-4194(ds, dwArg02);
	cup16 ax_n = (word16) dx_ax_n;
	word16 dx_n = SLICE(dx_ax_n, word16, 16);
	cui16 ax_n;
	if (true && (dx_n != 0x00 || ax_n >= 0x0400))
		ax_n = 0x0400;
	else
		ax_n = (word16) fn0800-4194(ds, dwArg02) & ~0x03;
	cui16 si_n;
	for (si_n = ax_n; si_n != 0x00; si_n -= 0x02)
	{
		word16 cx_n;
		word16 di_n;
		if (fn0800-3E27(ds, dwArg02, out cx_n, out di_n, out ds) == 21070)
		{
			word16 cx_n;
			word16 di_n;
			if ((fn0800-3E27(ds, dwArg02, out cx_n, out di_n, out ds) & 0xFF00) == 0x4300)
			{
				word16 cx_n;
				fn0800_ACB3(ds, dwArg02, ~0x03, 0x01, out cx_n);
				break;
			}
			word16 cx_n;
			fn0800_ACB3(ds, dwArg02, ~0x01, 0x01, out cx_n);
		}
	}
	dsOut = ds;
	return si_n;
}

// 0800:5E64: Register word16 fn0800-5E64(Register Eq_n ds, Register out Eq_n dsOut)
// Called from:
//      fn0800-0DE8
word16 fn0800-5E64(Eq_n ds, union Eq_n & dsOut)
{
	Eq_n ds_n;
	Eq_n ds_n;
	Eq_n ds_n;
	word16 si_n;
	Eq_n ds_n;
	word16 si_n;
	word16 cx_n;
	Eq_n ds_n;
	word16 di_n;
	Eq_n ds_n;
	word16 si_n;
	Eq_n dx_n;
	Eq_n ds_n;
	word16 di_n;
	mp16 fp;
	struct Eq_n Eq_n::* bp_n = fp - 2;
	mp16 sp_n = fp - 0x3E;
	word16 cx_n = 0x04;
	if (true)
		cx_n = 0x03;
	word16 ax_n = 0x00;
	Eq_n cmpResult_n = memcmp(*((word32) ds + 17009), *((word32) ds + 0x00002202), (uint32) cx_n);
	if (cmpResult_n != 0x00)
	{
		cup16 ax_n = 0x00 - (word16) (cmpResult_n < 0x00);
		ax_n = ax_n - ~0x00 - (word16) (ax_n < 0x00);
	}
	if (ax_n != 0x00)
	{
		cu16 cx_n = 0x04;
		word16 dx_n = ~0x00;
		if (false)
		{
			cx_n = 0x03;
			dx_n = 0x00;
		}
		uint16 cx_n = cx_n >> 0x01;
		memcpy(*((word32) ds + 17009), *((word32) ds + 0x00002202), cx_n *32 0x02);
		Eq_n SCZO_n;
		SCZO_n.u1 = cond(cx_n);
		<unknown>* di_n = cx_n * 0x02 + 17009;
		memcpy(di_n, cx_n * 0x02 + 0x2202, SCZO_n & 0x02);
		Eq_n di_n = (char *) di_n + ((word16) SCZO_n & 0x02);
		word16 cx_n;
		for (cx_n = dx_n; cx_n != 0x00; --cx_n)
		{
			ds->*di_n = 0x00;
			di_n = (word16) di_n + 1;
		}
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		bp_n = fn0800-09A3(ds, out ds);
		sp_n = (mp16) &sp_n.u5->t0008.u0;
	}
	Eq_n ax_n = (CONVERT(Mem129[ds:11893:byte], uint8, uint16) << 0x08) + CONVERT(Mem129[ds:11894:byte], uint8, uint16);
	if (Mem129[ds:0x2A09:word16] >u 0x00 || Mem129[ds:0x2A09:word16] == 0x00 && ax_n <u Mem129[ds:0x2A07:word16])
	{
		if (Mem129[ds:0x2A0B:word32] >u 0x7FF0)
		{
			Mem155[ds:0x2A0D:word16] = 0x00;
			Mem156[ds:0x2A0B:word16] = 0x7FF0;
		}
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		selector ss;
		(ss->*sp_n).t0000.u2 = (uint16) 0x00;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x00;
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) 0x02;
		Mem179[ss:sp_n + -6:word16] = Mem175[ds:0x29E5:word16];
		Mem182[ss:sp_n + -8:word16] = Mem179[ds:0x29E3:word16];
		word16 cx_n;
		fn0800_ACB3(ds, (ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3, (ss->*sp_n).t0000.u2, out cx_n);
		Mem197[ss:sp_n + 0x00:word16] = Mem182[ds:0x29E5:word16];
		Mem200[ss:sp_n + -2:word16] = Mem197[ds:0x29E3:word16];
		word16 di_n;
		Eq_n ds_n;
		(ss->*bp_n).tFFFFFFDE.u2 = (uint16) fn0800-3FAD(ds, (ss->*sp_n).tFFFFFFFE.u3, out di_n, out ds_n);
		Mem223[ss:sp_n + 0x00:word16] = Mem220[ds_n:0x29E5:word16];
		Mem226[ss:sp_n + -2:word16] = Mem223[ds_n:0x29E3:word16];
		Eq_n ax_n = fn0800-3FAD(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out di_n, out ds_n);
		Eq_n di_n = ax_n;
		if ((ss->*bp_n).tFFFFFFDE.u2 != 0x00)
			di_n = ax_n - 0x01;
		uint32 dx_ax_n = fn0800-8C69((uint32) di_n, 0x09).u3 + (uint32) ((ss->*bp_n).tFFFFFFDE).u2;
		(ss->*bp_n).tFFFFFFFE.u2 = SLICE(dx_ax_n, word16, 16);
		(ss->*bp_n).tFFFFFFFC.u2 = (uint16) (word16) dx_ax_n;
		if (Mem268[ss:bp_n + -4:word32] >u Mem268[ds_n:0x2A07:word32])
		{
			Eq_n dx_n = Mem268[ds_n:0x2A07:word16];
			Mem283[ss:bp_n + -2:word16] = Mem268[ds_n:0x2A09:word16];
			(ss->*bp_n).tFFFFFFFC.u2 = (uint16) dx_n;
		}
		Mem293[ss:sp_n + 0x00:word16] = Mem286[ds_n:0x29E5:word16];
		Mem296[ss:sp_n + -2:word16] = Mem293[ds_n:0x29E3:word16];
		word16 di_n;
		Eq_n ds_n;
		(ss->*bp_n).tFFFFFFDC.u2 = (uint16) fn0800-3FAD(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out di_n, out ds_n);
		Mem314[ss:sp_n + 0x00:word16] = Mem311[ds_n:0x29E5:word16];
		Mem317[ss:sp_n + -2:word16] = Mem314[ds_n:0x29E3:word16];
		word16 di_n;
		Eq_n ds_n;
		(ss->*bp_n).tFFFFFFDA.u2 = (uint16) fn0800-3FAD(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out di_n, out ds_n);
		Mem334[ss:sp_n + 0x00:word16] = Mem331[ds_n:0x29E5:word16];
		Mem337[ss:sp_n + -2:word16] = Mem334[ds_n:0x29E3:word16];
		word16 di_n;
		Eq_n ds_n;
		(ss->*bp_n).tFFFFFFD8.u2 = (uint16) fn0800-3FAD(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out di_n, out ds_n);
		Mem354[ss:sp_n + 0x00:word16] = Mem351[ds_n:0x29E5:word16];
		Mem357[ss:sp_n + -2:word16] = Mem354[ds_n:0x29E3:word16];
		word16 di_n;
		Eq_n ds_n;
		(ss->*bp_n).tFFFFFFD6.u2 = (uint16) fn0800-3FAD(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out di_n, out ds_n);
		Mem374[ss:sp_n + 0x00:word16] = Mem371[ds_n:0x29E5:word16];
		Mem377[ss:sp_n + -2:word16] = Mem374[ds_n:0x29E3:word16];
		word16 di_n;
		Eq_n ds_n;
		(ss->*bp_n).tFFFFFFD4.u2 = (uint16) fn0800-3FAD(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out di_n, out ds_n);
		Mem394[ss:sp_n + 0x00:word16] = Mem391[ds_n:0x29E5:word16];
		Mem397[ss:sp_n + -2:word16] = Mem394[ds_n:0x29E3:word16];
		word16 di_n;
		Eq_n ds_n;
		(ss->*bp_n).tFFFFFFD2.u2 = (uint16) fn0800-3FAD(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out di_n, out ds_n);
		Mem414[ss:sp_n + 0x00:word16] = Mem411[ds_n:0x29E5:word16];
		Mem417[ss:sp_n + -2:word16] = Mem414[ds_n:0x29E3:word16];
		word16 di_n;
		Eq_n ds_n;
		fn0800-3FAD(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out di_n, out ds_n);
		Mem433[ss:sp_n + 0x00:word16] = Mem417[ds_n:0x29E5:word16];
		Mem436[ss:sp_n + -2:word16] = Mem433[ds_n:0x29E3:word16];
		word16 di_n;
		Eq_n ds_n;
		(ss->*bp_n).tFFFFFFD0.u2 = (uint16) fn0800-3FAD(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out di_n, out ds_n);
		Mem453[ss:sp_n + 0x00:word16] = Mem450[ds_n:0x29E5:word16];
		Mem456[ss:sp_n + -2:word16] = Mem453[ds_n:0x29E3:word16];
		word16 di_n;
		Eq_n ds_n;
		(ss->*bp_n).tFFFFFFCE.u2 = (uint16) fn0800-3FAD(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out di_n, out ds_n);
		Mem473[ss:sp_n + 0x00:word16] = Mem470[ds_n:0x29E5:word16];
		Mem476[ss:sp_n + -2:word16] = Mem473[ds_n:0x29E3:word16];
		word16 di_n;
		Eq_n ds_n;
		(ss->*bp_n).tFFFFFFCC.u2 = (uint16) fn0800-3FAD(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out di_n, out ds_n);
		Mem493[ss:sp_n + 0x00:word16] = Mem490[ds_n:0x29E5:word16];
		Mem496[ss:sp_n + -2:word16] = Mem493[ds_n:0x29E3:word16];
		word16 di_n;
		Eq_n ds_n;
		fn0800-3FAD(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out di_n, out ds_n);
		Mem511[ss:sp_n + 0x00:word16] = Mem496[ds_n:10721:word16];
		Mem514[ss:sp_n + -2:word16] = Mem511[ds_n:10719:word16];
		Eq_n ax_n = (CONVERT(Mem514[ds_n:11893:byte], uint8, uint16) << 0x08) + CONVERT(Mem514[ds_n:11894:byte], uint8, uint16);
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) 0x00;
		(ss->*sp_n).tFFFFFFFA.u2 = (uint16) ax_n;
		(ss->*sp_n).tFFFFFFF8.u2 = (uint16) ds_n;
		(ss->*sp_n).tFFFFFFF6.u2 = (uint16) 0x2E77;
		word16 si_n;
		Eq_n ds_n;
		fn0800-4152(ds_n, (ss->*sp_n).tFFFFFFF6.u3, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3, out si_n, out ds_n);
		struct Eq_n Eq_n::* sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0000 + 2);
		if ((ss->*bp_n).tFFFFFFDC.u2 != 0x00)
		{
			(ss->*sp_n).t0000.u2 = (uint16) 0x00;
			(ss->*sp_n).tFFFFFFFE.u2 = (uint16) ~0x00;
			Eq_n ax_n = fn0800-4311(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out dx_n, out bp_n, out si_n, out ds_n);
			(ss->*bp_n).tFFFFFFF6.u2 = (uint16) dx_n;
			(ss->*bp_n).tFFFFFFF4.u2 = (uint16) ax_n;
			Eq_n sp_n;
			sp_n.u0 = <invalid>;
			(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x00;
			(ss->*sp_n.u5).t0000.u1.u2 = (uint16) 0x00;
			(ss->*((word32) sp_n - 2)).u2 = (ss->*bp_n).tFFFFFFCC.u2;
			Mem591[ss:sp_n + -4:word16] = Mem588[ds_n:0x29E5:word16];
			Mem594[ss:sp_n + -6:word16] = Mem591[ds_n:0x29E3:word16];
			word16 cx_n;
			fn0800_ACB3(ds_n, ss->*((word32) sp_n - 6), ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0002.u1.u2, out cx_n);
			(ss->*bp_n).tFFFFFFCA.u2 = (ss->*bp_n).tFFFFFFF4.u2;
			Eq_n si_n;
			si_n.u0 = 0x00;
			while (si_n != ((ss->*bp_n).tFFFFFFDC).u2)
			{
				Mem622[ss:sp_n + 0x02:word16] = Mem615[ds_n:0x29E5:word16];
				Mem625[ss:sp_n + 0x00:word16] = Mem622[ds_n:0x29E3:word16];
				word16 di_n;
				Eq_n ds_n;
				(ss->*bp_n).tFFFFFFDE.u2 = (uint16) fn0800-3FAD(ds_n, ss->*sp_n.u4, out di_n, out ds_n);
				Mem642[ss:sp_n + 0x02:word16] = Mem639[ds_n:0x29E5:word16];
				Mem645[ss:sp_n + 0x00:word16] = Mem642[ds_n:0x29E3:word16];
				uint32 dx_ax_n = fn0800-8C69((uint32) fn0800-3FAD(ds_n, ss->*sp_n.u4, out di_n, out ds_n), 0x04).u3 + (uint32) ((ss->*bp_n).tFFFFFFDE).u2;
				Eq_n es_n;
				es_n.u6 = (ss->*bp_n).tFFFFFFF6.u6;
				Eq_n bx_n;
				bx_n.u2 = (ss->*bp_n).tFFFFFFCA.u2;
				(es_n->*bx_n.u5).t0002.u1.u2 = SLICE(dx_ax_n, word16, 16);
				(es_n->*bx_n.u5).t0000.u1.u2 = (word16) dx_ax_n;
				(ss->*bp_n).tFFFFFFCA.u2 = (uint16) ((ss->*bp_n).tFFFFFFCA.u2 + 0x04);
				si_n.u3 = &si_n.u5->b0001;
			}
			(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x667B;
			(ss->*sp_n.u5).t0000.u1.u2 = (uint16) 0x04;
			(ss->*((word32) sp_n - 2)).u2 = (ss->*bp_n).tFFFFFFDC.u2;
			(ss->*((word32) sp_n - 4)).u2 = (ss->*bp_n).tFFFFFFF6.u2;
			(ss->*((word32) sp_n - 6)).u2 = (ss->*bp_n).tFFFFFFF4.u2;
			fn0800_B95E(ds_n, ss->*((word32) sp_n - 6), ss->*((word32) sp_n - 4), ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0000.u1.u2, (ss->*sp_n.u5).t0002.u1.u2);
			Eq_n di_n;
			di_n.u2 = (ss->*bp_n).tFFFFFFF4.u2;
			(ss->*bp_n).tFFFFFFC8.u0 = 0<32>;
			Eq_n si_n;
			si_n.u0 = 0x00;
			while (si_n != ((ss->*bp_n).tFFFFFFDC).u2)
			{
				Eq_n es_n;
				es_n.u6 = (ss->*bp_n).tFFFFFFF6.u6;
				cui16 ax_n = (es_n->*di_n.u5).t0002.u1.u2;
				Eq_n dx_n = (es_n->*di_n.u5).t0000.u1.u2;
				(ss->*bp_n).wFFFFFFEE = ax_n;
				(ss->*bp_n).tFFFFFFEC.u1 = (cui16) dx_n;
				(ss->*bp_n).wFFFFFFF2 = ax_n & 0x0F;
				(ss->*bp_n).tFFFFFFF0.u2 = (uint16) (dx_n & ~0x0F);
				Mem763[ss:sp_n + 0x02:word16] = Mem760[ds_n:10721:word16];
				Mem766[ss:sp_n + 0x00:word16] = Mem763[ds_n:10719:word16];
				(ss->*((word32) sp_n - 2)).u0 = 0x00;
				word16 cx_n;
				word16 dx_n;
				word16 bx_n;
				word16 di_n;
				Eq_n ds_n;
				fn0800-4047(ds_n, ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0000.u1.u3, out cx_n, out dx_n, out bx_n, out di_n, out ds_n);
				Mem787[ss:sp_n + 0x02:word16] = Mem771[ds_n:10721:word16];
				Mem790[ss:sp_n + 0x00:word16] = Mem787[ds_n:10719:word16];
				ss->*((word32) sp_n - 2) = (word16) fn0800-8CAA((ss->*bp_n).tFFFFFFF0.u3, 0x04);
				Eq_n di_n = fn0800-40BF(ds_n, (ss->*sp_n.u5).t0002.u0, ss->*sp_n.u4, out ds_n);
				(ss->*bp_n).tFFFFFFDE.u2 = (uint16) 0x00;
				do
				{
					Eq_n es_n;
					es_n.u6 = (ss->*bp_n).tFFFFFFF6.u6;
					ui32 ax_dx_n = es_n->*di_n.u4 - ((ss->*bp_n).tFFFFFFF0).u3;
					(ss->*bp_n).wFFFFFFEA = SLICE(ax_dx_n, word16, 16);
					(ss->*bp_n).tFFFFFFE8.u1 = (cup16) (word16) ax_dx_n;
					(ss->*bp_n).tFFFFFFF0.u3 += ax_dx_n;
					if ((ss->*bp_n).wFFFFFFEA > 0x00 || (ss->*bp_n).wFFFFFFEA == 0x00 && ((ss->*bp_n).tFFFFFFE8).u1 > 0xFF)
						break;
					ui32 ax_dx_n = (ss->*bp_n).tFFFFFFF0.u3 - ((ss->*bp_n).tFFFFFFEC).u0;
					cup16 ax_n = SLICE(ax_dx_n, word16, 16);
					cup16 dx_n = (word16) ax_dx_n;
					byte ah_n = SLICE(ax_n, byte, 8);
					if (ax_n > 0x00 || true && dx_n >= ~0x0F || ((ss->*bp_n).tFFFFFFDE).u2 == 0xFF)
						break;
					Mem873[ss:sp_n + 0x02:word16] = Mem837[ds_n:10721:word16];
					Mem876[ss:sp_n + 0x00:word16] = Mem873[ds_n:10719:word16];
					ss->*((word32) sp_n - 2) = SEQ(ah_n, (ss->*bp_n).tFFFFFFE8.u0);
					word16 cx_n;
					word16 dx_n;
					word16 bx_n;
					word16 di_n;
					fn0800-4047(ds_n, ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0000.u1.u3, out cx_n, out dx_n, out bx_n, out di_n, out ds_n);
					(ss->*bp_n).tFFFFFFDE.u2 = (uint16) ((ss->*bp_n).tFFFFFFDE.u2 + 0x01);
					di_n = di_n + 0x04;
					si_n.u3 = &si_n.u5->b0001;
				} while (si_n != ((ss->*bp_n).tFFFFFFDC).u2);
				(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x01;
				Eq_n ax_n;
				ax_n.u2 = (ss->*bp_n).tFFFFFFDE.u2;
				(ss->*sp_n.u5).t0000.u1.u2 = (uint16) ((ss->*bp_n).tFFFFFFC8.u0 - (ax_n != ~0x02));
				ss->*((word32) sp_n - 2) = -&ax_n.u5->b0003;
				Mem925[ss:sp_n + -4:word16] = Mem921[ds_n:10721:word16];
				Mem928[ss:sp_n + -6:word16] = Mem925[ds_n:10719:word16];
				byte ah_n = SLICE(fn0800_ACB3(ds_n, ss->*((word32) sp_n - 6), ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0002.u1.u2, out cx_n), byte, 8);
				Mem943[ss:sp_n + 0x02:word16] = Mem928[ds_n:10721:word16];
				Mem946[ss:sp_n + 0x00:word16] = Mem943[ds_n:10719:word16];
				ss->*((word32) sp_n - 2) = SEQ(ah_n, (ss->*bp_n).tFFFFFFDE.u0);
				word16 cx_n;
				word16 dx_n;
				word16 bx_n;
				fn0800-4047(ds_n, ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0000.u1.u3, out cx_n, out dx_n, out bx_n, out di_n, out ds_n);
				(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x01;
				uint32 dx_ax_n = (uint32) (ss->*bp_n).tFFFFFFDE.u2 + 0x02;
				(ss->*sp_n.u5).t0000.u1.u2 = SLICE(dx_ax_n, word16, 16);
				ss->*((word32) sp_n - 2) = (word16) dx_ax_n;
				Mem980[ss:sp_n + -4:word16] = Mem977[ds_n:10721:word16];
				Mem983[ss:sp_n + -6:word16] = Mem980[ds_n:10719:word16];
				word16 cx_n;
				fn0800_ACB3(ds_n, ss->*((word32) sp_n - 6), ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0002.u1.u2, out cx_n);
			}
			(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFF6.u2;
			(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).tFFFFFFF4.u2;
			word16 cx_n;
			word16 dx_n;
			word16 bx_n;
			fn0800-4346(ds_n, (ss->*sp_n.u5).t0002.u1.u2, out cx_n, out dx_n, out bx_n, out ds_n);
			sp_n = (struct Eq_n Eq_n::*) &sp_n.u5->t0004.u0;
		}
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		Mem1002[ss:sp_n + 0x00:word16] = Mem997[ds_n:10721:word16];
		Mem1005[ss:sp_n + -2:word16] = Mem1002[ds_n:10719:word16];
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) 0x00;
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		word16 di_n;
		Eq_n ds_n;
		fn0800-4047(ds_n, (ss->*sp_n).tFFFFFFFC.u0, (ss->*sp_n).tFFFFFFFE.u3, out cx_n, out dx_n, out bx_n, out di_n, out ds_n);
		Mem1028[ss:sp_n + 0x00:word16] = Mem1012[ds_n:10721:word16];
		Mem1031[ss:sp_n + -2:word16] = Mem1028[ds_n:10719:word16];
		Eq_n dx_ax_n = fn0800_AD2F(ds_n, (ss->*sp_n).tFFFFFFFE.u3);
		(ss->*bp_n).wFFFFFFE6 = SLICE((word32) dx_ax_n - 32, word16, 16);
		(ss->*bp_n).tFFFFFFE4.u1 = (cui16) ((word16) dx_ax_n + ~0x1F);
		while (((ss->*bp_n).tFFFFFFE4.u1 & 0x0F) != 0x00)
		{
			struct Eq_n Eq_n::* sp_n = sp_n - 2;
			Mem1064[ss:sp_n + 0x00:word16] = Mem1052[ds_n:10721:word16];
			Mem1067[ss:sp_n + -2:word16] = Mem1064[ds_n:10719:word16];
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) 0x00;
			word16 cx_n;
			word16 dx_n;
			word16 bx_n;
			word16 di_n;
			fn0800-4047(ds_n, (ss->*sp_n).tFFFFFFFC.u0, (ss->*sp_n).tFFFFFFFE.u3, out cx_n, out dx_n, out bx_n, out di_n, out ds_n);
			(ss->*bp_n).tFFFFFFE4.u0 = (ui32) ((ss->*bp_n).tFFFFFFE4.u0 + 0x01);
		}
		(ss->*bp_n).tFFFFFFFC.u3 = (char *) ((ss->*bp_n).tFFFFFFFC.u3 - (uint32) (((ss->*bp_n).tFFFFFFDA).u2 << 0x04));
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		(ss->*sp_n).t0000.u2 = (uint16) 0x00;
		Eq_n ax_n;
		ax_n.u2 = (ss->*bp_n).tFFFFFFDA.u2;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x00;
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) (ax_n << 0x04);
		Mem1116[ss:sp_n + -6:word16] = Mem1113[ds_n:0x29E5:word16];
		Mem1119[ss:sp_n + -8:word16] = Mem1116[ds_n:0x29E3:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, (ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3, (ss->*sp_n).t0000.u2, out cx_n);
		(ss->*sp_n).t0000.u2 = (ss->*bp_n).tFFFFFFFE.u2;
		(ss->*sp_n).tFFFFFFFE.u2 = (ss->*bp_n).tFFFFFFFC.u2;
		(ss->*sp_n).tFFFFFFFC.u2 = (ss->*bp_n).tFFFFFFFE.u2;
		(ss->*sp_n).tFFFFFFFA.u2 = (ss->*bp_n).tFFFFFFFC.u2;
		struct Eq_n Eq_n::* bp_n = fn0800-75EA(ds_n, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3, out si_n, out ds_n);
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		(ss->*sp_n.u5).t0006.u2 = (uint16) 0x00;
		(ss->*sp_n.u5).t0004.u1.u2 = (uint16) 0x00;
		(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x20;
		Mem1172[ss:sp_n + 0x00:word16] = Mem1169[ds_n:10721:word16];
		Mem1175[ss:sp_n + -2:word16] = Mem1172[ds_n:10719:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0002.u1.u3, (ss->*sp_n.u5).t0006.u2, out cx_n);
		Mem1190[ss:sp_n + 0x06:word16] = Mem1175[ds_n:10721:word16];
		Mem1193[ss:sp_n + 0x04:word16] = Mem1190[ds_n:10719:word16];
		(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFD0.u2;
		Eq_n ds_n;
		fn0800-40BF(ds_n, (ss->*sp_n.u5).t0002.u0, (ss->*sp_n.u5).t0004.u1.u3, out ds_n);
		Mem1212[ss:sp_n + 0x06:word16] = Mem1196[ds_n:10721:word16];
		Mem1215[ss:sp_n + 0x04:word16] = Mem1212[ds_n:10719:word16];
		(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFCE.u2;
		Eq_n ds_n;
		fn0800-40BF(ds_n, (ss->*sp_n.u5).t0002.u0, (ss->*sp_n.u5).t0004.u1.u3, out ds_n);
		Mem1234[ss:sp_n + 0x06:word16] = Mem1218[ds_n:10721:word16];
		Mem1237[ss:sp_n + 0x04:word16] = Mem1234[ds_n:10719:word16];
		(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFD2.u2;
		Eq_n ds_n;
		fn0800-40BF(ds_n, (ss->*sp_n.u5).t0002.u0, (ss->*sp_n.u5).t0004.u1.u3, out ds_n);
		Mem1256[ss:sp_n + 0x06:word16] = Mem1240[ds_n:10721:word16];
		Mem1259[ss:sp_n + 0x04:word16] = Mem1256[ds_n:10719:word16];
		(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFD4.u2;
		Eq_n ds_n;
		fn0800-40BF(ds_n, (ss->*sp_n.u5).t0002.u0, (ss->*sp_n.u5).t0004.u1.u3, out ds_n);
		Mem1278[ss:sp_n + 0x06:word16] = Mem1262[ds_n:10721:word16];
		Mem1281[ss:sp_n + 0x04:word16] = Mem1278[ds_n:10719:word16];
		(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFE4.u2;
		Eq_n ds_n;
		fn0800-40BF(ds_n, (ss->*sp_n.u5).t0002.u0, (ss->*sp_n.u5).t0004.u1.u3, out ds_n);
		Mem1310[ss:bp_n + -0x0022:word16] = SLICE(fn0800-8CAA(Mem1284[ds_n:0x2A03:ui32], 0x04), word16, 0);
		if ((Mem1310[ds_n:0x2A03:word16] & 0x0F) != 0x00)
			(ss->*bp_n).tFFFFFFDE.u2 = (uint16) ((ss->*bp_n).tFFFFFFDE.u2 + 0x01);
		Mem1327[ss:sp_n + 0x06:word16] = Mem1322[ds_n:10721:word16];
		Mem1330[ss:sp_n + 0x04:word16] = Mem1327[ds_n:10719:word16];
		(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFDE.u2;
		Eq_n ds_n;
		fn0800-40BF(ds_n, (ss->*sp_n.u5).t0002.u0, (ss->*sp_n.u5).t0004.u1.u3, out ds_n);
		Mem1350[ss:sp_n + 0x06:word16] = Mem1334[ds_n:10721:word16];
		Mem1353[ss:sp_n + 0x04:word16] = Mem1350[ds_n:10719:word16];
		(ss->*sp_n.u5).t0002.u1.u2 = (uint16) ((ss->*bp_n).tFFFFFFDE.u2 + (word16) fn0800-8CAA(((ss->*bp_n).tFFFFFFE4).u3, 0x04));
		Eq_n ds_n;
		fn0800-40BF(ds_n, (ss->*sp_n.u5).t0002.u0, (ss->*sp_n.u5).t0004.u1.u3, out ds_n);
		ui32 ax_dx_n = Mem1370[ss:bp_n + -4:ui32] - Mem1370[ds_n:0x2A03:ui32] + Mem1370[ds_n:0x4E88:ui32];
		(ss->*bp_n).tFFFFFFFA.u2 = SLICE(ax_dx_n + 0x80, word16, 16);
		(ss->*bp_n).tFFFFFFF8.u2 = (uint16) ((word16) ax_dx_n + 0x80);
		if (Mem1398[ds_n:10781:word16] != 0x00)
			(ss->*bp_n).tFFFFFFF8.u3 += 0x0200;
		else if (Mem1398[ds_n:0x2A21:word16] == 0x01)
			(ss->*bp_n).tFFFFFFF8.u3 += 384;
		(ss->*sp_n.u5).t0006.u2 = (uint16) 0x00;
		uint32 dx_bx_n = (ss->*bp_n).tFFFFFFFC.u3 + (uint32) ((ss->*bp_n).wFFFFFFDA << 0x04);
		(ss->*sp_n.u5).t0004.u1.u2 = SLICE(dx_bx_n, word16, 16);
		(ss->*sp_n.u5).t0002.u1.u2 = (uint16) (word16) dx_bx_n;
		Mem1440[ss:sp_n + 0x00:word16] = Mem1436[ds_n:0x29E5:word16];
		Mem1443[ss:sp_n + -2:word16] = Mem1440[ds_n:0x29E3:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0002.u1.u3, (ss->*sp_n.u5).t0006.u2, out cx_n);
		(ss->*sp_n.u5).t0006.u2 = (uint16) 0x02;
		(ss->*sp_n.u5).t0004.u1.u2 = (uint16) 0x00;
		(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x00;
		Mem1468[ss:sp_n + 0x00:word16] = Mem1465[ds_n:10721:word16];
		Mem1471[ss:sp_n + -2:word16] = Mem1468[ds_n:10719:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0002.u1.u3, (ss->*sp_n.u5).t0006.u2, out cx_n);
		Mem1486[ss:sp_n + 0x06:word16] = Mem1471[ds_n:10721:word16];
		Mem1489[ss:sp_n + 0x04:word16] = Mem1486[ds_n:10719:word16];
		Eq_n dx_ax_n = fn0800_AD2F(ds_n, (ss->*sp_n.u5).t0004.u1.u3);
		(ss->*bp_n).wFFFFFFE2 = SLICE(dx_ax_n, word16, 16);
		(ss->*bp_n).tFFFFFFE0.u2 = (uint16) (word16) dx_ax_n;
		ui32 dx_bx_n = Mem1501[ds_n:0x2A07:ui32] - Mem1501[ss:bp_n + -4:ui32] - CONVERT(Mem1501[ss:bp_n + -38:word16] << 0x04, uint16, uint32);
		(ss->*sp_n.u5).t0006.u2 = SLICE(dx_bx_n, word16, 16);
		(ss->*sp_n.u5).t0004.u1.u2 = (uint16) (word16) dx_bx_n;
		Mem1522[ss:sp_n + 0x02:word16] = Mem1519[ds_n:10721:word16];
		Mem1525[ss:sp_n + 0x00:word16] = Mem1522[ds_n:10719:word16];
		Mem1528[ss:sp_n + -2:word16] = Mem1525[ds_n:0x29E5:word16];
		Mem1531[ss:sp_n + -4:word16] = Mem1528[ds_n:0x29E3:word16];
		struct Eq_n Eq_n::* bp_n = fn0800-3B0A(ds_n, (ss->*sp_n.u5).t0004.u1.u2, (ss->*sp_n.u5).t0006.u2, out si_n, out ds_n);
		(ss->*bp_n).tFFFFFFDE.u2 = (uint16) ((ss->*bp_n).tFFFFFFE0.u2 & 0x01FF);
		fn0800-8CAA((ss->*bp_n).tFFFFFFE0.u3, 0x09);
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		(ss->*bp_n).tFFFFFFDE.u2 == 0x00;
		(ss->*sp_n.u5).t000A.u2 = (uint16) 0x00;
		(ss->*sp_n.u5).t0008.u2 = (uint16) 0x00;
		(ss->*sp_n.u5).t0006.u2 = (uint16) 0x02;
		Mem1586[ss:sp_n + 0x04:word16] = Mem1582[ds_n:10721:word16];
		Mem1589[ss:sp_n + 0x02:word16] = Mem1586[ds_n:10719:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, (ss->*sp_n.u5).t0002.u1.u3, (ss->*sp_n.u5).t0006.u3, (ss->*sp_n.u5).t000A.u2, out cx_n);
		Mem1604[ss:sp_n + 0x0A:word16] = Mem1589[ds_n:10721:word16];
		Mem1607[ss:sp_n + 0x08:word16] = Mem1604[ds_n:10719:word16];
		(ss->*sp_n.u5).t0006.u2 = (ss->*bp_n).tFFFFFFDE.u2;
		Eq_n di_n = fn0800-40BF(ds_n, (ss->*sp_n.u5).t0006.u0, (ss->*sp_n.u5).t0008.u3, out ds_n);
		Mem1627[ss:sp_n + 0x0A:word16] = Mem1611[ds_n:10721:word16];
		Mem1630[ss:sp_n + 0x08:word16] = Mem1627[ds_n:10719:word16];
		(ss->*sp_n.u5).t0006.u2 = (uint16) di_n;
		Eq_n ds_n;
		fn0800-40BF(ds_n, (ss->*sp_n.u5).t0006.u0, (ss->*sp_n.u5).t0008.u3, out ds_n);
		if (Mem1632[ds_n:10781:word16] != 0x00)
		{
			(ss->*sp_n.u5).t000A.u2 = (uint16) 0x00;
			(ss->*sp_n.u5).t0008.u2 = (uint16) 0x00;
			(ss->*sp_n.u5).t0006.u2 = (uint16) 0x2E;
			Mem1660[ss:sp_n + 0x04:word16] = Mem1657[ds_n:10721:word16];
			Mem1663[ss:sp_n + 0x02:word16] = Mem1660[ds_n:10719:word16];
			word16 cx_n;
			fn0800_ACB3(ds_n, (ss->*sp_n.u5).t0002.u1.u3, (ss->*sp_n.u5).t0006.u3, (ss->*sp_n.u5).t000A.u2, out cx_n);
			Mem1678[ss:sp_n + 0x0A:word16] = Mem1663[ds_n:10721:word16];
			Mem1681[ss:sp_n + 0x08:word16] = Mem1678[ds_n:10719:word16];
			(ss->*sp_n.u5).t0006.u2 = (ss->*bp_n).tFFFFFFDE.u2;
			Eq_n di_n = fn0800-40BF(ds_n, (ss->*sp_n.u5).t0006.u0, (ss->*sp_n.u5).t0008.u3, out ds_n);
			Mem1700[ss:sp_n + 0x0A:word16] = Mem1684[ds_n:10721:word16];
			Mem1703[ss:sp_n + 0x08:word16] = Mem1700[ds_n:10719:word16];
			(ss->*sp_n.u5).t0006.u2 = (uint16) di_n;
			fn0800-40BF(ds_n, (ss->*sp_n.u5).t0006.u0, (ss->*sp_n.u5).t0008.u3, out ds_n);
		}
		(ss->*sp_n.u5).t000A.u2 = (uint16) 0x00;
		(ss->*sp_n.u5).t0008.u2 = (uint16) 0x00;
		(ss->*sp_n.u5).t0006.u2 = (uint16) 0x18;
		Mem1735[ss:sp_n + 0x04:word16] = Mem1731[ds_n:10721:word16];
		Mem1738[ss:sp_n + 0x02:word16] = Mem1735[ds_n:10719:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, (ss->*sp_n.u5).t0002.u1.u3, (ss->*sp_n.u5).t0006.u3, (ss->*sp_n.u5).t000A.u2, out cx_n);
		Mem1752[ss:sp_n + 0x0A:word16] = Mem1738[ds_n:10721:word16];
		Mem1755[ss:sp_n + 0x08:word16] = Mem1752[ds_n:10719:word16];
		Mem1768[ss:sp_n + 0x06:word16] = (CONVERT(Mem1755[ds_n:11893:byte], uint8, uint16) << 0x08) + CONVERT(Mem1755[ds_n:11894:byte], uint8, uint16) - 0x20;
		Eq_n ds_n;
		fn0800-40BF(ds_n, (ss->*sp_n.u5).t0006.u0, (ss->*sp_n.u5).t0008.u3, out ds_n);
		(ss->*sp_n.u5).t000A.u2 = (uint16) 0x00;
		(ss->*sp_n.u5).t0008.u2 = (uint16) 0x00;
		(ss->*sp_n.u5).t0006.u2 = (uint16) 0x1C;
		Mem1794[ss:sp_n + 0x04:word16] = Mem1791[ds_n:10721:word16];
		Mem1797[ss:sp_n + 0x02:word16] = Mem1794[ds_n:10719:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, (ss->*sp_n.u5).t0002.u1.u3, (ss->*sp_n.u5).t0006.u3, (ss->*sp_n.u5).t000A.u2, out cx_n);
		Mem1812[ss:sp_n + 0x0A:word16] = Mem1797[ds_n:10721:word16];
		Mem1815[ss:sp_n + 0x08:word16] = Mem1812[ds_n:10719:word16];
		(ss->*sp_n.u5).t0006.u2 = (ss->*bp_n).tFFFFFFD8.u2;
		Eq_n ds_n;
		fn0800-40BF(ds_n, (ss->*sp_n.u5).t0006.u0, (ss->*sp_n.u5).t0008.u3, out ds_n);
		Mem1835[ss:sp_n + 0x0A:word16] = Mem1819[ds_n:10721:word16];
		Mem1838[ss:sp_n + 0x08:word16] = Mem1835[ds_n:10719:word16];
		(ss->*sp_n.u5).t0006.u2 = (ss->*bp_n).tFFFFFFD6.u2;
		Eq_n ds_n;
		fn0800-40BF(ds_n, (ss->*sp_n.u5).t0006.u0, (ss->*sp_n.u5).t0008.u3, out ds_n);
		(ss->*sp_n.u5).t000A.u2 = (uint16) 0x00;
		(ss->*sp_n.u5).t0008.u2 = (uint16) 0x00;
		(ss->*sp_n.u5).t0006.u2 = (uint16) 0x0A;
		Mem1867[ss:sp_n + 0x04:word16] = Mem1864[ds_n:10721:word16];
		Mem1870[ss:sp_n + 0x02:word16] = Mem1867[ds_n:10719:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, (ss->*sp_n.u5).t0002.u1.u3, (ss->*sp_n.u5).t0006.u3, (ss->*sp_n.u5).t000A.u2, out cx_n);
		if ((ss->*bp_n).tFFFFFFFC.u3 + (uint32) (((ss->*bp_n).tFFFFFFD8).u2 << 0x04) > ((ss->*bp_n).tFFFFFFF8).u3 + (((ss->*bp_n).tFFFFFFE0).u3 - 0x20))
			(ss->*bp_n).tFFFFFFF8.u3 += (ss->*bp_n).tFFFFFFFC.u3 + (uint32) (((ss->*bp_n).tFFFFFFD8).u2 << 0x04) - (((ss->*bp_n).tFFFFFFF8).u3 + (((ss->*bp_n).tFFFFFFE0).u3 - 0x20));
		(ss->*bp_n).tFFFFFFF8.u3 += (uint32) (0x10 - ((ss->*bp_n).t0008).u1 & 0x0F);
		Eq_n ax_n = (word16) fn0800-8CAA((ss->*bp_n).tFFFFFFF8.u3, 0x04);
		(ss->*bp_n).tFFFFFFD8.u2 = (uint16) ax_n;
		Mem1975[ss:sp_n + 0x0A:word16] = Mem1968[ds_n:10721:word16];
		Mem1978[ss:sp_n + 0x08:word16] = Mem1975[ds_n:10719:word16];
		(ss->*sp_n.u5).t0006.u2 = (uint16) ax_n;
		Eq_n ds_n;
		fn0800-40BF(ds_n, (ss->*sp_n.u5).t0006.u0, (ss->*sp_n.u5).t0008.u3, out ds_n);
		if ((ss->*bp_n).tFFFFFFD6.u2 < ((ss->*bp_n).tFFFFFFD8).u2)
			(ss->*bp_n).tFFFFFFD6.u2 = (ss->*bp_n).tFFFFFFD8.u2;
		Mem2004[ss:sp_n + 0x0A:word16] = Mem1999[ds_n:10721:word16];
		Mem2007[ss:sp_n + 0x08:word16] = Mem2004[ds_n:10719:word16];
		(ss->*sp_n.u5).t0006.u2 = (ss->*bp_n).tFFFFFFD6.u2;
		Eq_n ds_n;
		fn0800-40BF(ds_n, (ss->*sp_n.u5).t0006.u0, (ss->*sp_n.u5).t0008.u3, out ds_n);
		Eq_n ax_n = SLICE(fn0800-8CAA(Mem2011[ss:bp_n + -4:ui32] + Mem2011[ds_n:0x4E88:ui32] + 0x20, 0x04), word16, 0);
		(ss->*bp_n).tFFFFFFD4.u2 = (uint16) ax_n;
		Mem2048[ss:sp_n + 0x0A:word16] = Mem2045[ds_n:10721:word16];
		Mem2051[ss:sp_n + 0x08:word16] = Mem2048[ds_n:10719:word16];
		(ss->*sp_n.u5).t0006.u2 = (uint16) ax_n;
		Eq_n ds_n;
		fn0800-40BF(ds_n, (ss->*sp_n.u5).t0006.u0, (ss->*sp_n.u5).t0008.u3, out ds_n);
		(ss->*bp_n).tFFFFFFD2.u2 = (uint16) ((ss->*bp_n).tFFFFFFE4.u2 + 0x80);
		if (Mem2068[ds_n:10781:word16] != 0x00)
			(ss->*bp_n).tFFFFFFD2.u2 = (uint16) ((ss->*bp_n).tFFFFFFD2.u2 + 0x0200);
		else if (Mem2068[ds_n:0x2A21:word16] == 0x01)
			(ss->*bp_n).tFFFFFFD2.u2 = (uint16) ((ss->*bp_n).tFFFFFFD2.u2 + 0x0180);
		Mem2085[ss:sp_n + 0x0A:word16] = Mem2080[ds_n:10721:word16];
		Mem2088[ss:sp_n + 0x08:word16] = Mem2085[ds_n:10719:word16];
		(ss->*sp_n.u5).t0006.u2 = (ss->*bp_n).tFFFFFFD2.u2;
		Eq_n ds_n;
		fn0800-40BF(ds_n, (ss->*sp_n.u5).t0006.u0, (ss->*sp_n.u5).t0008.u3, out ds_n);
		Eq_n dx_bx_n = Mem2092[ds_n:0x2A07:ui32] - Mem2092[ss:bp_n + -4:ui32] - CONVERT(Mem2092[ss:bp_n + -38:word16] << 0x04, uint16, uint32);
		if (dx_bx_n == 0x00)
		{
			dsOut = ds_n;
			return 0x00;
		}
		else
		{
			dsOut = ds_n;
			return 0x01;
		}
	}
	else
	{
		dsOut = ds;
		return 0x03;
	}
}

// 0800:669C: Register word16 fn0800-669C(Register Eq_n ds, Register out Eq_n dsOut)
// Called from:
//      fn0800-0DE8
word16 fn0800-669C(Eq_n ds, union Eq_n & dsOut)
{
	mp16 fp;
	struct Eq_n Eq_n::* bp_n = fp - 2;
	if (Mem15[ds:0x2A07:word32] <=u 0xFEFE)
	{
		mp16 sp_n = fp - 0x0A;
		word16 cx_n = 0x04;
		if (true)
			cx_n = 0x03;
		word16 ax_n = 0x00;
		Eq_n cmpResult_n = memcmp(*((word32) ds + 17009), *((word32) ds + 0x00002206), (uint32) cx_n);
		if (cmpResult_n != 0x00)
		{
			cup16 ax_n = 0x00 - (word16) (cmpResult_n < 0x00);
			ax_n = ax_n - ~0x00 - (word16) (ax_n < 0x00);
		}
		if (ax_n != 0x00)
		{
			cu16 cx_n = 0x04;
			word16 dx_n = ~0x00;
			if (false)
			{
				cx_n = 0x03;
				dx_n = 0x00;
			}
			uint16 cx_n = cx_n >> 0x01;
			memcpy(*((word32) ds + 17009), *((word32) ds + 0x00002206), cx_n *32 0x02);
			Eq_n SCZO_n;
			SCZO_n.u1 = cond(cx_n);
			<unknown>* di_n = cx_n * 0x02 + 17009;
			memcpy(di_n, cx_n * 0x02 + 0x2206, SCZO_n & 0x02);
			Eq_n di_n = (char *) di_n + ((word16) SCZO_n & 0x02);
			word16 cx_n;
			for (cx_n = dx_n; cx_n != 0x00; --cx_n)
			{
				ds->*di_n = 0x00;
				di_n = (word16) di_n + 1;
			}
			Eq_n sp_n;
			sp_n.u0 = <invalid>;
			bp_n = fn0800-09A3(ds, out ds);
			sp_n = (mp16) &sp_n.u5->t0008.u0;
		}
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		selector ss;
		Mem144[ss:sp_n + 0x00:word16] = Mem137[ds:10721:word16];
		Mem147[ss:sp_n + -2:word16] = Mem144[ds:10719:word16];
		Eq_n ax_n = (CONVERT(Mem147[ds:11893:byte], uint8, uint16) << 0x08) + CONVERT(Mem147[ds:11894:byte], uint8, uint16);
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) 0x00;
		(ss->*sp_n).tFFFFFFFA.u2 = (uint16) ax_n;
		(ss->*sp_n).tFFFFFFF8.u2 = (uint16) ds;
		(ss->*sp_n).tFFFFFFF6.u2 = (uint16) 0x2E77;
		word16 si_n;
		Eq_n ds_n;
		fn0800-4152(ds, (ss->*sp_n).tFFFFFFF6.u3, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3, out si_n, out ds_n);
		uint32 dx_bx_n = Mem169[ds_n:0x2A07:ui32] + CONVERT((CONVERT(Mem169[ds_n:11893:byte], uint8, uint16) << 0x08) + CONVERT(Mem169[ds_n:11894:byte], uint8, uint16), uint16, uint32);
		(ss->*bp_n).tFFFFFFFE.u2 = SLICE(dx_bx_n + 0x40, word16, 16);
		(ss->*bp_n).tFFFFFFFC.u2 = (uint16) ((word16) dx_bx_n + 0x40);
		if (Mem207[ds_n:10781:word16] != 0x00)
			(ss->*bp_n).tFFFFFFFC.u3 += 0x0200;
		else if (Mem207[ds_n:0x2A21:word16] == 0x01)
			(ss->*bp_n).tFFFFFFFC.u3 += 384;
		if ((ss->*bp_n).tFFFFFFFC.u3 <= 0xFEFE)
		{
			Mem242[ss:sp_n + 0x00:word16] = Mem228[ds_n:0x2A09:word16];
			Mem245[ss:sp_n + -2:word16] = Mem242[ds_n:0x2A07:word16];
			Mem248[ss:sp_n + -4:word16] = Mem245[ds_n:0x2A09:word16];
			Mem251[ss:sp_n + -6:word16] = Mem248[ds_n:0x2A07:word16];
			word16 si_n;
			Eq_n ds_n;
			fn0800-75EA(ds_n, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3, out si_n, out ds_n);
			dsOut = ds_n;
			return 0x00;
		}
		else
		{
			dsOut = ds_n;
			return 0x03;
		}
	}
	else
	{
		dsOut = ds;
		return 0x03;
	}
}

// 0800:67BF: Register word16 fn0800-67BF(Register Eq_n ds, Register out Eq_n dsOut)
// Called from:
//      fn0800-0DE8
word16 fn0800-67BF(Eq_n ds, union Eq_n & dsOut)
{
	struct Eq_n * ds_n;
	Eq_n ds_n;
	Eq_n ds_n;
	word16 sp_n;
	struct Eq_n * ds_n;
	word16 si_n;
	selector ds_n;
	word16 si_n;
	Eq_n ax_n = (CONVERT(Mem7[ds:11893:byte], uint8, uint16) << 0x08) + CONVERT(Mem7[ds:11894:byte], uint8, uint16);
	if (Mem20[ds:0x2A09:word16] >u 0x00 || Mem20[ds:0x2A09:word16] == 0x00 && ax_n <u Mem20[ds:0x2A07:word16])
	{
		word16 si_n;
		Eq_n ds_n;
		fn0800-4152(ds, SEQ(ds, 0x2E77), ax_n, 0x00, Mem20[ds:10719:word32], out si_n, out ds_n);
		word16 cx_n;
		fn0800_ACB3(ds_n, Mem74[ds_n:10719:word32], ~0x11, 0x01, out cx_n);
		Eq_n ds_n;
		selector ss;
		if (fn0800-3F0A(ds_n, Mem80[ds_n:0x29E3:word32], out ds_n) != 0x601A)
		{
			Eq_n ds_n = fn0800-409C(ds_n, Mem312[ds_n:0x2A07:word16], Mem309[ds_n:0x2A09:word16], Mem98[ds_n:10719:word32]);
			word16 cx_n;
			fn0800_ACB3(ds_n, Mem339[ds_n:10719:word32], 0x0E, 0x01, out cx_n);
			struct Eq_n Eq_n::* bp_n = fn0800-75EA(ds_n, Mem366[ds_n:0x2A07:word16], Mem363[ds_n:0x2A09:word16], Mem345[ds_n:0x2A07:word32], out si_n, out ds_n);
			ui32 ax_dx_n = ds_n->dw2A07 - ds_n->dw2A03 + ds_n->dw4E88;
			(ss->*bp_n).tFFFFFFFA.u2 = SLICE(ax_dx_n + 0x0E, word16, 16);
			(ss->*bp_n).tFFFFFFF8.u2 = (uint16) ((word16) ax_dx_n + 0x0E);
			Eq_n sp_n;
			sp_n.u0 = <invalid>;
			word16 sp_n = (word16) &sp_n.u5->t0008.u0;
		}
		else
		{
			word16 cx_n;
			fn0800_ACB3(ds_n, Mem125[ds_n:0x29E3:word32], 0x02, 0x01, out cx_n);
			word16 si_n;
			Eq_n ds_n;
			fn0800-3B0A(ds_n, 0x10, 0x00, out si_n, out ds_n);
			Eq_n sp_n;
			sp_n.u0 = <invalid>;
			(ss->*sp_n.u5).t000A.u2 = (uint16) 0x00;
			(ss->*sp_n.u5).t0008.u2 = (uint16) 0x00;
			(ss->*sp_n.u5).t0006.u2 = (uint16) 0x1A;
			Mem192[ss:sp_n + 0x04:word16] = Mem189[ds_n:0x29E5:word16];
			Mem195[ss:sp_n + 0x02:word16] = Mem192[ds_n:0x29E3:word16];
			word16 cx_n;
			fn0800_ACB3(ds_n, (ss->*sp_n.u5).t0002.u1.u3, (ss->*sp_n.u5).t0006.u3, (ss->*sp_n.u5).t000A.u2, out cx_n);
			Mem210[ss:sp_n + 0x0A:word16] = Mem195[ds_n:10721:word16];
			Mem213[ss:sp_n + 0x08:word16] = Mem210[ds_n:10719:word16];
			Mem216[ss:sp_n + 0x06:word16] = Mem213[ds_n:0x29E5:word16];
			Mem219[ss:sp_n + 0x04:word16] = Mem216[ds_n:0x29E3:word16];
			word16 cx_n;
			word16 di_n;
			Eq_n ds_n;
			(ss->*sp_n.u5).t0006.u2 = (uint16) fn0800-3E27(ds_n, (ss->*sp_n.u5).t0004.u1.u3, out cx_n, out di_n, out ds_n);
			word16 cx_n;
			word16 dx_n;
			word16 bx_n;
			Eq_n ds_n;
			fn0800-401E(ds_n, (ss->*sp_n.u5).t0006.u0, (ss->*sp_n.u5).t0008.u3, out cx_n, out dx_n, out bx_n, out ds_n);
			Eq_n dx_n = Mem234[ds_n:0x2A07:word16];
			Mem254[ss:sp_n + 0x0A:word16] = SLICE(SEQ(Mem234[ds_n:0x2A09:word16], dx_n) - 0x1C, word16, 16);
			(ss->*sp_n.u5).t0008.u2 = (uint16) (dx_n - 0x1C);
			Eq_n dx_n = Mem256[ds_n:0x2A07:word16];
			Mem265[ss:sp_n + 0x06:word16] = SLICE(SEQ(Mem256[ds_n:0x2A09:word16], dx_n) - 0x1C, word16, 16);
			(ss->*sp_n.u5).t0004.u1.u2 = (uint16) (dx_n - 0x1C);
			struct Eq_n Eq_n::* bp_n = fn0800-75EA(ds_n, (ss->*sp_n.u5).t0004.u1.u2, (ss->*sp_n.u5).t0006.u2, (ss->*sp_n.u5).t0008.u3, out si_n, out ds_n);
			ui32 ax_dx_n = ds_n->dw2A07 - 0x1C - ds_n->dw2A03 + ds_n->dw4E88;
			(ss->*bp_n).tFFFFFFFA.u2 = SLICE(ax_dx_n + 0x0E, word16, 16);
			(ss->*bp_n).tFFFFFFF8.u2 = (uint16) ((word16) ax_dx_n + 0x0E);
			Eq_n sp_n;
			sp_n.u0 = <invalid>;
			word16 sp_n = (word16) &sp_n.u5->t0008.u0;
		}
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		Eq_n ds_n;
		Mem408[ss:sp_n + 0x00:word16] = Mem403[ds_n:10721:word16];
		Mem411[ss:sp_n + -2:word16] = Mem408[ds_n:10719:word16];
		struct Eq_n Eq_n::* bp_n;
		if (((word16) fn0800_AD2F(ds_n, (ss->*sp_n).tFFFFFFFE.u3) & 0x01) != 0x00)
		{
			Mem430[ss:sp_n + 0x00:word16] = Mem411[ds_n:10721:word16];
			Mem433[ss:sp_n + -2:word16] = Mem430[ds_n:10719:word16];
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) 0x90;
			word16 cx_n;
			word16 dx_n;
			word16 bx_n;
			word16 di_n;
			selector ds_n;
			fn0800-4047(ds_n, (ss->*sp_n).tFFFFFFFC.u0, (ss->*sp_n).tFFFFFFFE.u3, out cx_n, out dx_n, out bx_n, out di_n, out ds_n);
			++(ss->*bp_n).tFFFFFFF8.u3;
		}
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		Eq_n ds_n;
		Mem465[ss:sp_n + 0x00:word16] = Mem460[ds_n:10721:word16];
		Mem468[ss:sp_n + -2:word16] = Mem465[ds_n:10719:word16];
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) 0x00;
		(ss->*sp_n).tFFFFFFFA.u2 = (uint16) 0x00;
		Eq_n ds_n = fn0800-409C(ds_n, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3);
		Mem492[ss:sp_n + 0x00:word16] = Mem476[ds_n:10721:word16];
		Mem495[ss:sp_n + -2:word16] = Mem492[ds_n:10719:word16];
		Eq_n dx_ax_n = fn0800_AD2F(ds_n, (ss->*sp_n).tFFFFFFFE.u3);
		Mem510[ds_n:0x2A05:word16] = SLICE(dx_ax_n + ~0x1F, word16, 16);
		Mem511[ds_n:0x2A03:word16] = SLICE(dx_ax_n, word16, 0) + ~0x1F;
		(ss->*sp_n).t0000.u2 = (uint16) 0x00;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x00;
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) 0x02;
		Mem525[ss:sp_n + -6:word16] = Mem522[ds_n:10721:word16];
		Mem528[ss:sp_n + -8:word16] = Mem525[ds_n:10719:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, (ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3, (ss->*sp_n).t0000.u2, out cx_n);
		Mem543[ss:sp_n + 0x00:word16] = Mem528[ds_n:10721:word16];
		Mem546[ss:sp_n + -2:word16] = Mem543[ds_n:10719:word16];
		word16 di_n;
		Eq_n ds_n;
		(ss->*bp_n).tFFFFFFF8.u3 = (char *) ((ss->*bp_n).tFFFFFFF8.u3 - fn0800-3F58(ds_n, ((ss->*sp_n).tFFFFFFFE).u3, out di_n, out ds_n));
		Mem570[ss:sp_n + 0x00:word16] = Mem566[ds_n:10721:word16];
		Mem573[ss:sp_n + -2:word16] = Mem570[ds_n:10719:word16];
		Mem576[ss:sp_n + -4:word16] = Mem573[ds_n:0x2A05:word16];
		Mem579[ss:sp_n + -6:word16] = Mem576[ds_n:0x2A03:word16];
		Eq_n ds_n = fn0800-409C(ds_n, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3);
		(ss->*sp_n).t0000.u2 = (uint16) 0x00;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x00;
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) 0x00;
		Mem604[ss:sp_n + -6:word16] = Mem601[ds_n:0x29E5:word16];
		Mem607[ss:sp_n + -8:word16] = Mem604[ds_n:0x29E3:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, (ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3, (ss->*sp_n).t0000.u2, out cx_n);
		Mem622[ss:sp_n + 0x00:word16] = Mem607[ds_n:0x29E5:word16];
		Mem625[ss:sp_n + -2:word16] = Mem622[ds_n:0x29E3:word16];
		word16 cx_n;
		word16 di_n;
		Eq_n ds_n;
		if (fn0800-3E27(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out cx_n, out di_n, out ds_n) == 0x601A)
		{
			Mem642[ss:sp_n + 0x00:word16] = Mem625[ds_n:0x29E5:word16];
			Mem645[ss:sp_n + -2:word16] = Mem642[ds_n:0x29E3:word16];
			Eq_n dx_ax_n = fn0800-3E5D(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out ds_n);
			(ss->*sp_n).t0000.u2 = (uint16) (word16) dx_ax_n;
			(ss->*sp_n).tFFFFFFFE.u2 = SLICE(dx_ax_n, word16, 16);
			Mem665[ss:sp_n + -4:word16] = Mem662[ds_n:0x29E5:word16];
			Mem668[ss:sp_n + -6:word16] = Mem665[ds_n:0x29E3:word16];
			ui32 bx_cx_n = fn0800-3E5D(ds_n, (ss->*sp_n).tFFFFFFFA.u3, out ds_n).u3 + SEQ(((ss->*sp_n).tFFFFFFFE).u2, ((ss->*sp_n).t0000).u2);
			(ss->*bp_n).wFFFFFFFE = SLICE(bx_cx_n, word16, 16);
			(ss->*bp_n).tFFFFFFFC.u1 = (word16) (word16) bx_cx_n;
			Mem694[ss:sp_n + 0x00:word16] = Mem691[ds_n:0x29E5:word16];
			Mem697[ss:sp_n + -2:word16] = Mem694[ds_n:0x29E3:word16];
			Eq_n dx_ax_n = fn0800-3E5D(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out ds_n);
			(ss->*bp_n).wFFFFFFF6 = SLICE(dx_ax_n, word16, 16);
			(ss->*bp_n).tFFFFFFF4.u1 = (word16) (word16) dx_ax_n;
			if ((ss->*bp_n).tFFFFFFFC.u0 + ((ss->*bp_n).tFFFFFFF4).u0 > ((ss->*bp_n).tFFFFFFF8).u3 + ds_n->dw2A03)
				(ss->*bp_n).tFFFFFFF8.u3 += (ss->*bp_n).tFFFFFFFC.u0 + ((ss->*bp_n).tFFFFFFF4).u0 - (((ss->*bp_n).tFFFFFFF8).u3 + ds_n->dw2A03);
		}
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		(ss->*sp_n).t0000.u2 = (uint16) 0x00;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x00;
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) 0x0A;
		Eq_n ds_n;
		Mem773[ss:sp_n + -6:word16] = Mem769[ds_n:10721:word16];
		Mem776[ss:sp_n + -8:word16] = Mem773[ds_n:10719:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, (ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3, (ss->*sp_n).t0000.u2, out cx_n);
		Mem791[ss:sp_n + 0x00:word16] = Mem776[ds_n:10721:word16];
		Mem794[ss:sp_n + -2:word16] = Mem791[ds_n:10719:word16];
		(ss->*sp_n).tFFFFFFFC.u2 = (ss->*bp_n).tFFFFFFFA.u2;
		(ss->*sp_n).tFFFFFFFA.u2 = (ss->*bp_n).tFFFFFFF8.u2;
		dsOut = fn0800-409C(ds_n, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3);
		return 0x00;
	}
	else
	{
		dsOut = ds;
		return 0x03;
	}
}

// 0800:6AD4: Register word16 fn0800-6AD4(Register Eq_n ds, Register out Eq_n dsOut)
// Called from:
//      fn0800-0DE8
word16 fn0800-6AD4(Eq_n ds, union Eq_n & dsOut)
{
	word16 cx_n;
	Eq_n ds_n;
	Eq_n ds_n;
	Eq_n ds_n;
	Eq_n ds_n;
	Eq_n ds_n;
	Eq_n ds_n;
	Eq_n ds_n;
	Eq_n ax_n = (CONVERT(Mem12[ds:11893:byte], uint8, uint16) << 0x08) + CONVERT(Mem12[ds:11894:byte], uint8, uint16);
	if (Mem12[ds:0x2A09:word16] >u 0x00 || Mem12[ds:0x2A09:word16] == 0x00 && ax_n <u Mem12[ds:0x2A07:word16])
	{
		Eq_n dx_ax_n = fn0800-3E5D(ds, Mem12[ds:0x29E3:word32], out ds_n);
		word16 ax_n = (word16) dx_ax_n;
		if (SLICE(dx_ax_n, word16, 16) != 0x00 || ax_n != 1011)
		{
			dsOut = ds_n;
			return 0x03;
		}
		else
		{
			Eq_n ds_n = fn0800-409C(ds_n, 1011, 0x00, Mem38[ds_n:10719:word32]);
			Eq_n dx_ax_n;
			do
			{
				Eq_n ds_n;
				dx_ax_n = fn0800-3E5D(ds_n, Mem87[ds_n:0x29E3:word32], out ds_n);
				Eq_n ax_n = (word16) dx_ax_n;
				Eq_n dx_n;
				dx_n.u3 = SLICE(dx_ax_n, word16, 16);
				ds_n = fn0800-409C(ds_n, ax_n, dx_n, Mem113[ds_n:10719:word32]);
				Eq_n dwLoc0A_n = dx_ax_n;
				while (true)
				{
					uint16 wLoc0A_n = (word16) dwLoc0A_n;
					ui16 v30_n = SLICE(dwLoc0A_n - 0x01, word16, 16);
					if (dwLoc0A_n == 0x00)
						break;
					Eq_n v50_n = Mem148[ds_n:10721:word16];
					Eq_n v51_n = Mem158[ds_n:10719:word16];
					Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem161[ds_n:0x29E3:word32], out ds_n);
					ds_n = fn0800-409C(ds_n, (word16) dx_ax_n, SLICE(dx_ax_n, word16, 16), SEQ(v50_n, v51_n));
					dwLoc0A_n = SEQ(v30_n, wLoc0A_n - 0x01);
				}
			} while (dx_ax_n != 0x00);
			Eq_n v31_n = Mem148[ds_n:10721:word16];
			Eq_n v32_n = Mem206[ds_n:10719:word16];
			Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem209[ds_n:0x29E3:word32], out ds_n);
			Eq_n ds_n = fn0800-409C(ds_n, (word16) dx_ax_n + 0x01, SLICE(&dx_ax_n.u5->b0001, word16, 16), SEQ(v31_n, v32_n));
			Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem236[ds_n:0x29E3:word32], out ds_n);
			Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem270[ds_n:0x29E3:word32], out ds_n);
			Eq_n ds_n = fn0800-409C(ds_n, (word16) dx_ax_n, SLICE(dx_ax_n, word16, 16), Mem303[ds_n:10719:word32]);
			Eq_n ds_n = fn0800-409C(ds_n, (word16) dx_ax_n + 0x01, SLICE(&dx_ax_n.u5->b0001, word16, 16), Mem315[ds_n:10719:word32]);
			Eq_n ds_n = fn0800-409C(ds_n, (CONVERT(Mem344[ds_n:11893:byte], uint8, uint16) << 0x08) + CONVERT(Mem344[ds_n:11894:byte], uint8, uint16) - 0x0C >>u 0x02, 0x00, Mem370[ds_n:10719:word32]);
			Eq_n dx_ax_n = fn0800_AD2F(ds_n, Mem385[ds_n:10719:word32]);
			Mem416[ds_n:20110:word16] = SLICE(dx_ax_n, word16, 16);
			Mem417[ds_n:20108:word16] = SLICE(dx_ax_n, word16, 0);
			ui32 ax_dx_n = dx_ax_n - dx_ax_n;
			Eq_n dwLoc06_n = SEQ(SLICE(ax_dx_n + 0x01, word16, 16), (word16) ax_dx_n + 0x01);
			while (true)
			{
				uint16 wLoc06_n = (word16) dwLoc06_n;
				if (dwLoc06_n == 0x00)
					break;
				Eq_n v56_n = Mem424[ds_n:10721:word16];
				Eq_n v57_n = Mem435[ds_n:10719:word16];
				Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem438[ds_n:0x29E3:word32], out ds_n);
				ds_n = fn0800-409C(ds_n, (word16) dx_ax_n, SLICE(dx_ax_n, word16, 16), SEQ(v56_n, v57_n));
				dwLoc06_n = SEQ(SLICE(dwLoc06_n - 0x01, word16, 16), wLoc06_n - 0x01);
			}
			word16 si_n;
			Eq_n ds_n;
			fn0800-4152(ds_n, SEQ(ds_n, 0x2E77), (CONVERT(Mem486[ds_n:11893:byte], uint8, uint16) << 0x08) + CONVERT(Mem486[ds_n:11894:byte], uint8, uint16), 0x00, Mem424[ds_n:10719:word32], out si_n, out ds_n);
			Eq_n dx_ax_n = fn0800_AD2F(ds_n, Mem508[ds_n:0x29E3:word32]);
			Eq_n ax_n = (word16) dx_ax_n;
			Eq_n dx_n;
			dx_n.u3 = SLICE(dx_ax_n, word16, 16);
			if (dx_n >=u Mem531[ds_n:0x2A09:word16] && (dx_n != Mem531[ds_n:0x2A09:word16] || ax_n >=u Mem531[ds_n:0x2A07:word16]))
			{
				dsOut = ds_n;
				return 0x00;
			}
			else
			{
				Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem531[ds_n:0x29E3:word32], out ds_n);
				word16 ax_n = (word16) dx_ax_n;
				cui16 dx_n = SLICE(dx_ax_n, word16, 16);
				word16 cx_n;
				struct Eq_n seg0800_t::* bx_n = (struct Eq_n seg0800_t::*) seg0800_t::a6EBC;
				for (cx_n = 0x07; cx_n != 0x00; --cx_n)
				{
					if ((0x0800->*bx_n).w0000 == ax_n && bx_n[7] == (dx_n & 0x3FFF))
					{
						bx_n[0x0E]();
						dsOut = ds_n;
						byte ch_n = SLICE(cx_n, byte, 8);
						word16 ax_n;
						return ax_n;
					}
					++bx_n;
				}
				dsOut = ds_n;
				return 0x09;
			}
		}
	}
	else
	{
		dsOut = ds;
		return 0x03;
	}
}

word16 g_a6EBC[] = // 0800:6EBC
	{
	};
cui16 g_a6ECA[] = // 0800:6ECA
	{
	};
Eq_n g_a6ED8[] = // 0800:6ED8
	{
	};
// 0800:6EE6: void fn0800-6EE6(Register Eq_n cx, Register Eq_n dx, Register Eq_n bx, Register Eq_n ds)
void fn0800-6EE6(Eq_n cx, Eq_n dx, Eq_n bx, Eq_n ds)
{
	word16 di_n;
	fn0800_B2EF(cx, dx, bx, ds, SEQ(ds, 0x2223), out di_n);
}

// 0800:6EFF: void fn0800-6EFF(Register Eq_n cx, Register Eq_n dx, Register Eq_n bx, Register Eq_n ds, Stack cup16 wArg02)
void fn0800-6EFF(Eq_n cx, Eq_n dx, Eq_n bx, Eq_n ds, cup16 wArg02)
{
	word16 di_n;
	fn0800_B2EF(cx, dx, bx, ds, SEQ(ds, 0x2231), out di_n);
	if (wArg02 > 0x09)
	{
		word16 di_n;
		fn0800_B2EF(cx, dx, bx, ds, SEQ(ds, 0x223E), out di_n);
	}
}

// 0800:6F20: void fn0800-6F20(Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n wArg04)
void fn0800-6F20(Eq_n ds, Eq_n wArg02, Eq_n wArg04)
{
	Eq_n ds_n;
	Eq_n ds_n;
	Eq_n ds_n;
	word16 di_n;
	Eq_n ds_n;
	word16 si_n;
	Eq_n ds_n;
	word16 di_n;
	mp16 fp;
	Eq_n ds_n;
	Eq_n dx_ax_n = fn0800-8C69(fn0800-3E5D(ds, Mem7[ds:0x29E3:word32], out ds_n), 0x02);
	ui32 dx_ax_n = fn0800_AD2F(ds_n, Mem42[ds_n:0x29E3:word32]);
	word16 cx_n;
	fn0800_ACB3(ds_n, Mem70[ds_n:0x29E3:word32], dx_ax_n, 0x01, out cx_n);
	struct Eq_n Eq_n::* bp_n = fp - 2;
	Eq_n dx_n;
	dx_n.u3 = SLICE(dx_ax_n, word16, 16);
	Eq_n ax_n = (word16) dx_ax_n;
	while (true)
	{
		Eq_n dx_ax_n = fn0800-3F58(ds_n, Mem90[ds_n:0x29E3:word32], out di_n, out ds_n);
		word16 ax_n = (word16) dx_ax_n;
		if (SLICE(dx_ax_n, word16, 16) != 0x00 || ax_n != 1004)
			break;
		word16 cx_n;
		fn0800_ACB3(ds_n, Mem130[ds_n:0x29E3:word32], 0x04, 0x01, out cx_n);
		Eq_n dx_ax_n;
		do
		{
			dx_ax_n = fn0800-8C69(fn0800-3E5D(ds_n, Mem150[ds_n:0x29E3:word32], out ds_n), 0x02);
			word16 ax_n = (word16) dx_ax_n;
			if (dx_ax_n != 0x00)
			{
				word16 cx_n;
				fn0800_ACB3(ds_n, Mem203[ds_n:0x29E3:word32], SEQ(SLICE(dx_ax_n + 0x04, word16, 16), ax_n + 0x04), 0x01, out cx_n);
			}
		} while (dx_ax_n != 0x00);
	}
	int32 dx_ax_n = fn0800_AD2F(ds_n, Mem98[ds_n:0x29E3:word32]) - dx_ax_n;
	Eq_n dx_n;
	dx_n.u3 = SLICE(dx_ax_n, word16, 16);
	Mem260[ds_n:0x2A05:word16] = dx_n;
	Eq_n ax_n = (word16) dx_ax_n;
	Mem261[ds_n:0x2A03:word16] = ax_n;
	Eq_n ds_n = fn0800-409C(ds_n, wArg02, wArg04, Mem261[ds_n:10719:word32]);
	ui32 dx_ax_n = fn0800_AD2F(ds_n, Mem273[ds_n:10719:word32]);
	mp16 sp_n = fp - 0x1C;
	if (dx_n >= 0x00 && (dx_n > 0x00 || ax_n > 0x12))
	{
		word16 cx_n;
		fn0800_ACB3(ds_n, Mem324[ds_n:10719:word32], Mem317[ds_n:20108:word32], 0x00, out cx_n);
		Eq_n dx_ax_n = fn0800-3E5D(ds_n, Mem330[ds_n:10719:word32], out ds_n);
		word16 cx_n;
		fn0800_ACB3(ds_n, Mem375[ds_n:10719:word32], dx_ax_n, 0x00, out cx_n);
		Eq_n ds_n = fn0800-409C(ds_n, 0x00, 0x00, Mem381[ds_n:10719:word32]);
		Eq_n ds_n = fn0800-409C(ds_n, ax_n, dx_n, Mem406[ds_n:10719:word32]);
		Eq_n ds_n = fn0800-409C(ds_n, (word16) dx_ax_n, SLICE(dx_ax_n, word16, 16), Mem431[ds_n:10719:word32]);
		word16 cx_n;
		fn0800_ACB3(ds_n, Mem480[ds_n:0x29E3:word32], dx_ax_n, 0x00, out cx_n);
		word16 si_n;
		bp_n = fn0800-75EA(ds_n, ax_n, dx_n, SEQ(SLICE(dx_ax_n - 0x08, word16, 16), ax_n - 0x08), out si_n, out ds_n);
		Mem535[ds_n:0x2A03:ui32] = Mem531[ds_n:0x2A03:ui32] + 0x08;
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		sp_n = (mp16) &sp_n.u5->t0008.u0;
	}
	Eq_n ax_n = Mem538[ds_n:0x2A05:word16];
	Eq_n dx_n = Mem538[ds_n:0x2A03:word16];
	selector ss;
	if (ax_n >= ((ss->*bp_n).tFFFFFFEA).u2 && (ax_n != ((ss->*bp_n).tFFFFFFEA).u2 || dx_n >= ((ss->*bp_n).tFFFFFFE8).u2))
	{
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		(ss->*sp_n).t0000.u2 = (uint16) 0x00;
		(ss->*sp_n).tFFFFFFFE.u2 = (ss->*bp_n).tFFFFFFFE.u2;
		(ss->*sp_n).tFFFFFFFC.u2 = (ss->*bp_n).tFFFFFFFC.u2;
		Mem567[ss:sp_n + -6:word16] = Mem563[ds_n:10721:word16];
		Mem570[ss:sp_n + -8:word16] = Mem567[ds_n:10719:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, (ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3, (ss->*sp_n).t0000.u2, out cx_n);
		(ss->*sp_n).t0000.u2 = (uint16) 0x00;
		uint16 dx_n = (ss->*bp_n).wFFFFFFEC;
		(ss->*sp_n).tFFFFFFFE.u2 = SLICE(SEQ((ss->*bp_n).wFFFFFFEE, dx_n) - 0x04, word16, 16);
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) (dx_n - 0x04);
		Mem598[ss:sp_n + -6:word16] = Mem595[ds_n:0x29E5:word16];
		Mem601[ss:sp_n + -8:word16] = Mem598[ds_n:0x29E3:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, (ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3, (ss->*sp_n).t0000.u2, out cx_n);
		uint16 dx_n = (ss->*bp_n).wFFFFFFF0;
		(ss->*sp_n).t0000.u2 = SLICE(SEQ((ss->*bp_n).tFFFFFFF2.u2, dx_n) + 0x04, word16, 16);
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) (dx_n + 0x04);
		Mem626[ss:sp_n + -4:word16] = Mem623[ds_n:10721:word16];
		Mem629[ss:sp_n + -6:word16] = Mem626[ds_n:10719:word16];
		Mem632[ss:sp_n + -8:word16] = Mem629[ds_n:0x29E5:word16];
		Mem635[ss:sp_n + -0x0A:word16] = Mem632[ds_n:0x29E3:word16];
		struct Eq_n Eq_n::* bp_n = fn0800-3B0A(ds_n, (ss->*sp_n).tFFFFFFFE.u2, (ss->*sp_n).t0000.u2, out si_n, out ds_n);
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		Mem654[ss:sp_n + 0x0A:word16] = Mem635[ds_n:0x29E5:word16];
		Mem657[ss:sp_n + 0x08:word16] = Mem654[ds_n:0x29E3:word16];
		Eq_n dx_ax_n = fn0800-3F58(ds_n, (ss->*sp_n.u5).t0008.u3, out di_n, out ds_n);
		word16 ax_n = (word16) dx_ax_n;
		if (SLICE(dx_ax_n, word16, 16) == 0x00 && ax_n == 1004)
		{
			(ss->*sp_n.u5).t000A.u2 = (uint16) 0x01;
			(ss->*sp_n.u5).t0008.u2 = (uint16) 0x00;
			(ss->*sp_n.u5).t0006.u2 = (uint16) 0x04;
			Mem692[ss:sp_n + 0x04:word16] = Mem689[ds_n:0x29E5:word16];
			Mem695[ss:sp_n + 0x02:word16] = Mem692[ds_n:0x29E3:word16];
			word16 cx_n;
			fn0800_ACB3(ds_n, (ss->*sp_n.u5).t0002.u1.u3, (ss->*sp_n.u5).t0006.u3, (ss->*sp_n.u5).t000A.u2, out cx_n);
			Mem709[ss:sp_n + 0x0A:word16] = Mem695[ds_n:10721:word16];
			Mem712[ss:sp_n + 0x08:word16] = Mem709[ds_n:10719:word16];
			(ss->*sp_n.u5).t0006.u2 = (uint16) 0x00;
			(ss->*sp_n.u5).t0004.u1.u2 = (uint16) 1004;
			ds_n = fn0800-409C(ds_n, (ss->*sp_n.u5).t0004.u1.u2, (ss->*sp_n.u5).t0006.u2, (ss->*sp_n.u5).t0008.u3);
			struct Eq_n Eq_n::* sp_n = (struct Eq_n Eq_n::*) &sp_n.u5->t000C.u0;
			do
			{
				struct Eq_n Eq_n::* sp_n = sp_n - 2;
				Mem741[ss:sp_n + 0x00:word16] = Mem736[ds_n:0x29E5:word16];
				Mem744[ss:sp_n + -2:word16] = Mem741[ds_n:0x29E3:word16];
				Eq_n dx_ax_n = fn0800-3E5D(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out ds_n);
				(ss->*bp_n).tFFFFFFFE.u2 = SLICE(dx_ax_n, word16, 16);
				Eq_n ax_n = (word16) dx_ax_n;
				(ss->*bp_n).tFFFFFFFC.u2 = (uint16) ax_n;
				Mem763[ss:sp_n + 0x00:word16] = Mem760[ds_n:10721:word16];
				Mem766[ss:sp_n + -2:word16] = Mem763[ds_n:10719:word16];
				(ss->*sp_n).tFFFFFFFC.u2 = (ss->*bp_n).tFFFFFFFE.u2;
				(ss->*sp_n).tFFFFFFFA.u2 = (uint16) ax_n;
				ds_n = fn0800-409C(ds_n, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3);
				sp_n = (struct Eq_n Eq_n::*) &sp_n->t0002.u0;
				if (((ss->*bp_n).tFFFFFFFC.u2 | ((ss->*bp_n).tFFFFFFFE).u2) != 0x00)
				{
					Mem792[ss:sp_n + 0x00:word16] = Mem771[ds_n:0x29E5:word16];
					Mem795[ss:sp_n + -2:word16] = Mem792[ds_n:0x29E3:word16];
					Eq_n dx_ax_n = fn0800-3E5D(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out ds_n);
					(ss->*bp_n).tFFFFFFFA.u2 = SLICE(&dx_ax_n.u5->b0001, word16, 16);
					word16 ax_n = (word16) dx_ax_n;
					(ss->*bp_n).tFFFFFFF8.u2 = (uint16) (ax_n + 0x01);
					Mem817[ss:sp_n + 0x00:word16] = Mem814[ds_n:10721:word16];
					Mem820[ss:sp_n + -2:word16] = Mem817[ds_n:10719:word16];
					(ss->*sp_n).tFFFFFFFC.u2 = (ss->*bp_n).tFFFFFFFA.u2;
					(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (ax_n + 0x01);
					Eq_n ds_n = fn0800-409C(ds_n, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3);
					Eq_n dx_ax_n = fn0800-8C69((ss->*bp_n).tFFFFFFFC.u3, 0x02);
					(ss->*sp_n).t0000.u2 = SLICE(dx_ax_n, word16, 16);
					(ss->*sp_n).tFFFFFFFE.u2 = (uint16) (word16) dx_ax_n;
					Mem857[ss:sp_n + -4:word16] = Mem854[ds_n:10721:word16];
					Mem860[ss:sp_n + -6:word16] = Mem857[ds_n:10719:word16];
					Mem863[ss:sp_n + -8:word16] = Mem860[ds_n:0x29E5:word16];
					Mem866[ss:sp_n + -0x0A:word16] = Mem863[ds_n:0x29E3:word16];
					Eq_n sp_n;
					sp_n.u0 = <invalid>;
					word16 si_n;
					bp_n = fn0800-3B0A(ds_n, (ss->*sp_n).tFFFFFFFE.u2, (ss->*sp_n).t0000.u2, out si_n, out ds_n);
					sp_n = (struct Eq_n Eq_n::*) &sp_n.u5->t000C.u0;
				}
			} while (((ss->*bp_n).tFFFFFFFC.u2 | ((ss->*bp_n).tFFFFFFFE).u2) != 0x00);
		}
		Mem900[ds_n:20108:ui32] = Mem896[ds_n:20108:ui32] + 0x04;
	}
	else
	{
		ui32 ax_dx_n = Mem538[ss:bp_n + -24:ui32] + Mem538[ds_n:0x4E88:ui32];
		(ss->*bp_n).tFFFFFFFE.u2 = SLICE(ax_dx_n, word16, 16);
		(ss->*bp_n).tFFFFFFFC.u2 = (uint16) (word16) ax_dx_n;
		if ((Mem918[ds_n:0x2A03:word16] & 0x03) != 0x00)
			(ss->*bp_n).tFFFFFFFC.u3 += 2;
		if (((ss->*bp_n).tFFFFFFFC.u2 & 0x03) != 0x00)
		{
			int32 dx_ax_n = fn0800-8CAA((ss->*bp_n).tFFFFFFFC.u3, 0x02);
			(ss->*bp_n).tFFFFFFFE.u2 = SLICE(dx_ax_n + 0x01, word16, 16);
			(ss->*bp_n).tFFFFFFFC.u2 = (uint16) ((word16) dx_ax_n + 0x01);
		}
		else
		{
			int32 dx_ax_n = fn0800-8CAA((ss->*bp_n).tFFFFFFFC.u3, 0x02);
			(ss->*bp_n).tFFFFFFFE.u2 = SLICE(dx_ax_n, word16, 16);
			(ss->*bp_n).tFFFFFFFC.u2 = (uint16) (word16) dx_ax_n;
		}
		while ((Mem977[ds_n:0x2A03:word16] & 0x03) != 0x00)
		{
			struct Eq_n Eq_n::* sp_n = sp_n - 2;
			Mem989[ss:sp_n + 0x00:word16] = Mem977[ds_n:10721:word16];
			Mem992[ss:sp_n + -2:word16] = Mem989[ds_n:10719:word16];
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) 0x00;
			word16 cx_n;
			word16 dx_n;
			word16 bx_n;
			word16 di_n;
			fn0800-4047(ds_n, (ss->*sp_n).tFFFFFFFC.u0, (ss->*sp_n).tFFFFFFFE.u3, out cx_n, out dx_n, out bx_n, out di_n, out ds_n);
			Mem1015[ds_n:0x2A03:ui32] = Mem1011[ds_n:0x2A03:ui32] + 0x01;
		}
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		Mem1019[ss:sp_n + 0x00:word16] = Mem977[ds_n:10721:word16];
		Mem1022[ss:sp_n + -2:word16] = Mem1019[ds_n:10719:word16];
		Eq_n dx_ax_n = fn0800_AD2F(ds_n, (ss->*sp_n).tFFFFFFFE.u3);
		(ss->*bp_n).tFFFFFFFA.u2 = SLICE(dx_ax_n, word16, 16);
		(ss->*bp_n).tFFFFFFF8.u2 = (uint16) (word16) dx_ax_n;
		(ss->*sp_n).t0000.u2 = (uint16) 0x01;
		ui32 ax_dx_n = -Mem1038[ds_n:0x2A03:ui32];
		(ss->*sp_n).tFFFFFFFE.u2 = SLICE(ax_dx_n - 0x04, word16, 16);
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) ((word16) ax_dx_n - 0x04);
		Mem1056[ss:sp_n + -6:word16] = Mem1053[ds_n:10721:word16];
		Mem1059[ss:sp_n + -8:word16] = Mem1056[ds_n:10719:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, (ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3, (ss->*sp_n).t0000.u2, out cx_n);
		Mem1074[ss:sp_n + 0x00:word16] = Mem1059[ds_n:10721:word16];
		Mem1077[ss:sp_n + -2:word16] = Mem1074[ds_n:10719:word16];
		int32 dx_ax_n = fn0800-8CAA(Mem1077[ds_n:0x2A03:ui32], 0x02);
		(ss->*sp_n).tFFFFFFFC.u2 = SLICE(dx_ax_n, word16, 16);
		(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (word16) dx_ax_n;
		Eq_n ds_n = fn0800-409C(ds_n, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3);
		Eq_n ax_n;
		ax_n.u2 = (ss->*bp_n).tFFFFFFF6.u2;
		Eq_n dx_n;
		dx_n.u2 = (ss->*bp_n).tFFFFFFF4.u2;
		(ss->*bp_n).tFFFFFFE6.u2 = (uint16) (ax_n & 0x3FFF);
		if (SEQ(ax_n & 0x3FFF, dx_n) > ((ss->*bp_n).tFFFFFFFC).u3)
		{
			Eq_n ax_n;
			ax_n.u2 = (ss->*bp_n).tFFFFFFF4.u2;
			(ss->*bp_n).tFFFFFFFE.u2 = (ss->*bp_n).tFFFFFFE6.u2;
			(ss->*bp_n).tFFFFFFFC.u2 = (uint16) ax_n;
		}
		Eq_n ax_n;
		ax_n.u2 = (ss->*bp_n).tFFFFFFF6.u2;
		(ss->*bp_n).tFFFFFFFC.u2 = (ss->*bp_n).tFFFFFFFC.u2;
		(ss->*bp_n).tFFFFFFFE.u2 = (uint16) ((ss->*bp_n).tFFFFFFFE.u2 | ax_n & 0xC000);
		(ss->*sp_n).t0000.u2 = (uint16) 0x00;
		Mem1145[ss:sp_n + -2:word16] = Mem1140[ds_n:20110:word16];
		Mem1148[ss:sp_n + -4:word16] = Mem1145[ds_n:20108:word16];
		Mem1151[ss:sp_n + -6:word16] = Mem1148[ds_n:10721:word16];
		Mem1154[ss:sp_n + -8:word16] = Mem1151[ds_n:10719:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, (ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3, (ss->*sp_n).t0000.u2, out cx_n);
		Mem1169[ss:sp_n + 0x00:word16] = Mem1154[ds_n:10721:word16];
		Mem1172[ss:sp_n + -2:word16] = Mem1169[ds_n:10719:word16];
		(ss->*sp_n).tFFFFFFFC.u2 = (ss->*bp_n).tFFFFFFFE.u2;
		(ss->*sp_n).tFFFFFFFA.u2 = (ss->*bp_n).tFFFFFFFC.u2;
		Eq_n ds_n = fn0800-409C(ds_n, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3);
		(ss->*sp_n).t0000.u2 = (uint16) 0x00;
		(ss->*sp_n).tFFFFFFFE.u2 = (ss->*bp_n).tFFFFFFFA.u2;
		(ss->*sp_n).tFFFFFFFC.u2 = (ss->*bp_n).tFFFFFFF8.u2;
		Mem1205[ss:sp_n + -6:word16] = Mem1202[ds_n:10721:word16];
		Mem1208[ss:sp_n + -8:word16] = Mem1205[ds_n:10719:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, (ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3, (ss->*sp_n).t0000.u2, out cx_n);
		Mem1225[ds_n:20108:ui32] = Mem1221[ds_n:20108:ui32] + 0x04;
	}
}

// 0800:73AC: Register word16 fn0800-73AC(Register Eq_n ds, Register out (ptr16 Eq_n) dsOut)
// Called from:
//      fn0800-0DE8
word16 fn0800-73AC(Eq_n ds, struct Eq_n & dsOut)
{
	word16 si_n;
	Eq_n ds_n;
	fn0800-4152(ds, SEQ(ds, 0x2E77), (CONVERT(Mem12[ds:11893:byte], uint8, uint16) << 0x08) + CONVERT(Mem12[ds:11894:byte], uint8, uint16), 0x00, Mem0[ds:10719:word32], out si_n, out ds_n);
	word16 cx_n;
	fn0800_ACB3(ds_n, Mem57[ds_n:10719:word32], ~0x03, 0x01, out cx_n);
	Eq_n ds_n = fn0800-409C(ds_n, Mem84[ds_n:0x2A0F:word16], Mem81[ds_n:0x2A11:word16], Mem63[ds_n:10719:word32]);
	word16 si_n;
	struct Eq_n * ds_n;
	fn0800-75EA(ds_n, Mem109[ds_n:0x2A07:word16], Mem106[ds_n:0x2A09:word16], Mem87[ds_n:0x2A07:word32], out si_n, out ds_n);
	dsOut = ds_n;
	return 0x00;
}

// 0800:741D: Register word16 fn0800-741D(Register Eq_n ds)
// Called from:
//      fn0800-0DE8
word16 fn0800-741D(Eq_n ds)
{
	Eq_n ds_n;
	word16 di_n;
	Eq_n ds_n;
	mp16 fp;
	struct Eq_n Eq_n::* bp_n = fp - 2;
	struct Eq_n Eq_n::* sp_n = fp - 0x08;
	while (true)
	{
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		selector ss;
		Mem20[ss:sp_n + 0x00:word16] = Mem15[ds:0x29E5:word16];
		Mem23[ss:sp_n + -2:word16] = Mem20[ds:0x29E3:word16];
		Eq_n dx_ax_n = fn0800_AD2F(ds, (ss->*sp_n).tFFFFFFFE.u3);
		Eq_n ax_n = (word16) dx_ax_n;
		Eq_n dx_n;
		dx_n.u3 = SLICE(dx_ax_n, word16, 16);
		if (dx_n >=u Mem23[ds:0x2A09:word16] && (dx_n != Mem23[ds:0x2A09:word16] || ax_n >=u Mem23[ds:0x2A07:word16]))
			break;
		Mem58[ss:sp_n + 0x00:word16] = Mem23[ds:0x29E5:word16];
		Mem61[ss:sp_n + -2:word16] = Mem58[ds:0x29E3:word16];
		word16 ax_n = fn0800-3E9A(ds, (ss->*sp_n).tFFFFFFFE.u3, out ds);
		switch (ax_n)
		{
		case 0x00:
			Mem82[ss:sp_n + 0x00:word16] = Mem61[ds:10721:word16];
			Mem85[ss:sp_n + -2:word16] = Mem82[ds:10719:word16];
			Mem88[ss:sp_n + -4:word16] = Mem85[ds:0x29E5:word16];
			Mem91[ss:sp_n + -6:word16] = Mem88[ds:0x29E3:word16];
			byte ch_n;
			word16 di_n;
			Eq_n ds_n;
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) fn0800-3DCF(ds, (ss->*sp_n).tFFFFFFFA.u3, out ch_n, out di_n, out ds_n);
			word16 cx_n;
			word16 dx_n;
			word16 bx_n;
			word16 di_n;
			fn0800-4047(ds_n, (ss->*sp_n).tFFFFFFFC.u0, (ss->*sp_n).tFFFFFFFE.u3, out cx_n, out dx_n, out bx_n, out di_n, out ds);
			sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0000 + 2);
			break;
		case 0x01:
			Mem124[ss:sp_n + 0x00:word16] = Mem61[ds:10721:word16];
			Mem127[ss:sp_n + -2:word16] = Mem124[ds:10719:word16];
			Mem130[ss:sp_n + -4:word16] = Mem127[ds:0x29E5:word16];
			Mem133[ss:sp_n + -6:word16] = Mem130[ds:0x29E3:word16];
			Eq_n dx_ax_n = fn0800-3E5D(ds, (ss->*sp_n).tFFFFFFFA.u3, out ds_n);
			(ss->*sp_n).tFFFFFFFC.u2 = SLICE(dx_ax_n, word16, 16);
			(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (word16) dx_ax_n;
			Eq_n ds_n = fn0800-409C(ds_n, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3);
			Mem166[ss:sp_n + 0x00:word16] = Mem150[ds_n:0x29E5:word16];
			Mem169[ss:sp_n + -2:word16] = Mem166[ds_n:0x29E3:word16];
			Eq_n ax_n = fn0800-3FAD(ds_n, (ss->*sp_n).tFFFFFFFE.u3, out di_n, out ds_n);
			(ss->*bp_n).tFFFFFFFE.u2 = (uint16) 0x00;
			(ss->*bp_n).tFFFFFFFC.u2 = (uint16) ax_n;
			Mem187[ss:sp_n + 0x00:word16] = Mem184[ds_n:10721:word16];
			Mem190[ss:sp_n + -2:word16] = Mem187[ds_n:10719:word16];
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) 0x00;
			word16 cx_n;
			word16 dx_n;
			word16 bx_n;
			Eq_n ds_n;
			fn0800-401E(ds_n, (ss->*sp_n).t0004.u0, (ss->*sp_n).tFFFFFFFE.u3, out cx_n, out dx_n, out bx_n, out ds_n);
			(ss->*sp_n).t0000.u2 = (ss->*bp_n).tFFFFFFFE.u2;
			(ss->*sp_n).tFFFFFFFE.u2 = (ss->*bp_n).tFFFFFFFC.u2;
			(ss->*sp_n).tFFFFFFFC.u2 = (ss->*bp_n).tFFFFFFFE.u2;
			(ss->*sp_n).tFFFFFFFA.u2 = (ss->*bp_n).tFFFFFFFC.u2;
			word16 si_n;
			Eq_n ds_n;
			bp_n = fn0800-75EA(ds_n, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3, out si_n, out ds_n);
			Eq_n sp_n;
			sp_n.u0 = <invalid>;
			(ss->*sp_n.u5).t0006.u2 = (uint16) 0x01;
			Eq_n dx_n = Mem239[ds_n:0x2A03:word16];
			Mem252[ss:sp_n + 0x04:word16] = -SLICE(SEQ(Mem239[ds_n:0x2A05:word16], dx_n) + 0x02, word16, 16) - (dx_n != ~0x01);
			(ss->*sp_n.u5).t0002.u1.u2 = (uint16) -((word16) dx_n.u2 + 2);
			Mem257[ss:sp_n + 0x00:word16] = Mem254[ds_n:10721:word16];
			Mem260[ss:sp_n + -2:word16] = Mem257[ds_n:10719:word16];
			word16 cx_n;
			fn0800_ACB3(ds_n, ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0002.u1.u3, (ss->*sp_n.u5).t0006.u2, out cx_n);
			Mem275[ss:sp_n + 0x06:word16] = Mem260[ds_n:10721:word16];
			Mem278[ss:sp_n + 0x04:word16] = Mem275[ds_n:10719:word16];
			Mem281[ss:sp_n + 0x02:word16] = Mem278[ds_n:0x2A03:word16];
			fn0800-40BF(ds_n, (ss->*sp_n.u5).t0002.u0, (ss->*sp_n.u5).t0004.u1.u3, out ds);
			Eq_n dx_n = Mem281[ds:0x2A03:word16];
			if (Mem281[ds:0x2A05:word16] == Mem281[ss:bp_n + -2:word16] && dx_n == ((ss->*bp_n).tFFFFFFFC).u2)
			{
				(ss->*sp_n.u5).t0006.u2 = (uint16) 0x01;
				ui32 ax_dx_n = -(ss->*bp_n).tFFFFFFFC.u3;
				(ss->*sp_n.u5).t0004.u1.u2 = SLICE(ax_dx_n, word16, 16);
				(ss->*sp_n.u5).t0002.u1.u2 = (uint16) (word16) ax_dx_n;
				Mem346[ss:sp_n + 0x00:word16] = Mem343[ds:0x29E5:word16];
				Mem349[ss:sp_n + -2:word16] = Mem346[ds:0x29E3:word16];
				word16 cx_n;
				fn0800_ACB3(ds, ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0002.u1.u3, (ss->*sp_n.u5).t0006.u2, out cx_n);
				(ss->*sp_n.u5).t0006.u2 = (ss->*bp_n).tFFFFFFFE.u2;
				(ss->*sp_n.u5).t0004.u1.u2 = (ss->*bp_n).tFFFFFFFC.u2;
				Mem370[ss:sp_n + 0x02:word16] = Mem367[ds:10721:word16];
				Mem373[ss:sp_n + 0x00:word16] = Mem370[ds:10719:word16];
				Mem376[ss:sp_n + -2:word16] = Mem373[ds:0x29E5:word16];
				Mem379[ss:sp_n + -4:word16] = Mem376[ds:0x29E3:word16];
				Eq_n sp_n;
				sp_n.u0 = <invalid>;
				word16 si_n;
				bp_n = fn0800-3B0A(ds, (ss->*sp_n.u5).t0004.u1.u2, (ss->*sp_n.u5).t0006.u2, out si_n, out ds);
				sp_n = (struct Eq_n Eq_n::*) &sp_n.u5->t000C.u0;
			}
			else
			{
				(ss->*sp_n.u5).t0006.u2 = (uint16) 0x01;
				Mem308[ss:sp_n + 0x04:word16] = Mem304[ds:0x2A05:word16];
				Mem311[ss:sp_n + 0x02:word16] = Mem308[ds:0x2A03:word16];
				Mem314[ss:sp_n + 0x00:word16] = Mem311[ds:10721:word16];
				Mem317[ss:sp_n + -2:word16] = Mem314[ds:10719:word16];
				word16 cx_n;
				fn0800_ACB3(ds, ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0002.u1.u3, (ss->*sp_n.u5).t0006.u2, out cx_n);
				sp_n = (struct Eq_n Eq_n::*) &sp_n.u5->t0008.u0;
			}
			break;
		case 0x03:
			word16 si_n;
			for (si_n = 0x00; si_n != 0x03; ++si_n)
			{
				struct Eq_n Eq_n::* sp_n = sp_n - 2;
				Mem466[ss:sp_n + 0x00:word16] = Mem461[ds:10721:word16];
				Mem469[ss:sp_n + -2:word16] = Mem466[ds:10719:word16];
				Mem472[ss:sp_n + -4:word16] = Mem469[ds:0x29E5:word16];
				Mem475[ss:sp_n + -6:word16] = Mem472[ds:0x29E3:word16];
				byte ch_n;
				word16 di_n;
				Eq_n ds_n;
				(ss->*sp_n).tFFFFFFFC.u2 = (uint16) fn0800-3DCF(ds, (ss->*sp_n).tFFFFFFFA.u3, out ch_n, out di_n, out ds_n);
				word16 cx_n;
				word16 dx_n;
				word16 bx_n;
				word16 di_n;
				fn0800-4047(ds_n, (ss->*sp_n).tFFFFFFFC.u0, (ss->*sp_n).tFFFFFFFE.u3, out cx_n, out dx_n, out bx_n, out di_n, out ds);
			}
			break;
		default:
			Mem400[ss:sp_n + 0x00:word16] = Mem61[ds:0x29E5:word16];
			Mem403[ss:sp_n + -2:word16] = Mem400[ds:0x29E3:word16];
			ui32 bx_cx_n = Mem403[ds:0x2A07:ui32] - fn0800_AD2F(ds, Mem403[ss:sp_n + -2:segptr32]);
			(ss->*sp_n).t0000.u2 = SLICE(bx_cx_n, word16, 16);
			(ss->*sp_n).tFFFFFFFE.u2 = (uint16) (word16) bx_cx_n;
			Mem427[ss:sp_n + -4:word16] = Mem424[ds:10721:word16];
			Mem430[ss:sp_n + -6:word16] = Mem427[ds:10719:word16];
			Mem433[ss:sp_n + -8:word16] = Mem430[ds:0x29E5:word16];
			Mem436[ss:sp_n + -0x0A:word16] = Mem433[ds:0x29E3:word16];
			Eq_n sp_n;
			sp_n.u0 = <invalid>;
			word16 si_n;
			bp_n = fn0800-3B0A(ds, (ss->*sp_n).tFFFFFFFE.u2, (ss->*sp_n).t0000.u2, out si_n, out ds);
			sp_n = (struct Eq_n Eq_n::*) &sp_n.u5->t000C.u0;
			break;
		}
	}
	return 0x00;
}

// 0800:75EA: Register word16 fn0800-75EA(Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n wArg04, Stack Eq_n dwArg06, Register out Eq_n siOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-0DE8
//      fn0800-12E2
//      fn0800-5E64
//      fn0800-669C
//      fn0800-67BF
//      fn0800-6F20
//      fn0800-73AC
//      fn0800-741D
word16 fn0800-75EA(Eq_n ds, Eq_n wArg02, Eq_n wArg04, Eq_n dwArg06, union Eq_n & siOut, union Eq_n & dsOut)
{
	Eq_n ds_n;
	word16 si_n;
	Eq_n dx_n;
	Eq_n ds_n;
	word16 si_n;
	struct Eq_n Eq_n::* bp_n;
	word16 dx_n;
	Eq_n ds_n;
	word16 si_n;
	struct Eq_n Eq_n::* bp_n;
	word16 dx_n;
	Eq_n ds_n;
	word16 si_n;
	struct Eq_n Eq_n::* bp_n;
	word16 dx_n;
	Eq_n ds_n;
	word16 si_n;
	struct Eq_n Eq_n::* bp_n;
	word16 dx_n;
	mp16 fp;
	word16 wArg06 = (word16) dwArg06;
	Mem16[ds:0x4680:word16] = wArg04;
	Mem17[ds:0x467E:word16] = wArg02;
	Mem18[ds:0x2A05:word16] = wArg04;
	Mem19[ds:0x2A03:word16] = wArg02;
	Mem20[ds:18040:word16] = wArg04;
	Mem21[ds:0x4676:word16] = wArg02;
	Mem28[ds:20102:word16] = SLICE(dwArg06 - 0x12, word16, 16);
	Mem29[ds:20100:word16] = wArg06 - 0x12;
	struct Eq_n Eq_n::* bp_n = fp - 2;
	struct Eq_n Eq_n::* sp_n = fp - 0x1A;
	selector ss;
	if (Mem29[ds:0x4680:word16] >u 0x00 || Mem29[ds:0x4680:word16] == 0x00 && wArg02 > 0x12)
	{
		Mem36[ds:11851:word16] = 0x00;
		Mem37[ds:11849:word16] = 0x00;
		Mem38[ds:18012:word16] = 0x00;
		Mem39[ds:0x4668:word16] = 0x00;
		Mem40[ds:0x4666:word16] = 0x00;
		Mem41[ds:0x2A05:word16] = 0x00;
		Mem42[ds:0x2A03:word16] = 0x00;
		Mem43[ds:0x2A01:word16] = 0x00;
		Mem44[ds:0x29FF:word16] = 0x00;
		Mem45[ds:18044:word16] = 0x00;
		Mem46[ds:0x467A:word16] = 0x00;
		Mem47[ds:0x4674:word16] = 0x00;
		Mem48[ds:0x4672:word16] = 0x00;
		Mem49[ds:11843:word16] = 0x00;
		Mem50[ds:11845:word16] = 0x00;
		Mem51[ds:20098:word16] = 0x00;
		Mem52[ds:20106:word16] = 0x00;
		Mem53[ds:0x4E88:word16] = 0x00;
		Mem54[ds:0x29F9:word16] = 0x00;
		Mem55[ds:0x29F7:word16] = 0x00;
		Eq_n ax_n = fn0800-4311(ds, 0x0001000F, out dx_n, out bp_n, out si_n, out ds_n);
		(ss->*bp_n).wFFFFFFEC = dx_n;
		(ss->*bp_n).tFFFFFFEA.u2 = (uint16) ax_n;
		Mem84[ds_n:11891:word16] = dx_n + 0x01;
		Mem85[ds_n:11889:word16] = 0x00;
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x01;
		(ss->*sp_n.u5).t0000.u1.u2 = (uint16) 0x10;
		Eq_n ax_n = fn0800-4311(ds_n, ss->*sp_n.u4, out dx_n, out bp_n, out si_n, out ds_n);
		(ss->*bp_n).wFFFFFFF0 = dx_n;
		(ss->*bp_n).tFFFFFFEE.u2 = (uint16) ax_n;
		Mem112[ds_n:11833:word16] = dx_n + 0x01;
		Mem113[ds_n:11831:word16] = 0x00;
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x01;
		(ss->*sp_n.u5).t0000.u1.u2 = (uint16) 0x10;
		Eq_n ax_n = fn0800-4311(ds_n, ss->*sp_n.u4, out dx_n, out bp_n, out si_n, out ds_n);
		(ss->*bp_n).wFFFFFFF4 = dx_n;
		(ss->*bp_n).tFFFFFFF2.u2 = (uint16) ax_n;
		Mem140[ds_n:11829:word16] = dx_n + 0x01;
		Mem141[ds_n:0x2E33:word16] = 0x00;
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x01;
		(ss->*sp_n.u5).t0000.u1.u2 = (uint16) 0x10;
		Eq_n ax_n = fn0800-4311(ds_n, ss->*sp_n.u4, out dx_n, out bp_n, out si_n, out ds_n);
		(ss->*bp_n).wFFFFFFF8 = dx_n;
		(ss->*bp_n).tFFFFFFF6.u2 = (uint16) ax_n;
		Mem168[ds_n:11841:word16] = dx_n + 0x01;
		Mem169[ds_n:11839:word16] = 0x00;
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x01;
		(ss->*sp_n.u5).t0000.u1.u2 = (uint16) 0x10;
		Eq_n ax_n = fn0800-4311(ds_n, ss->*sp_n.u4, out dx_n, out bp_n, out si_n, out ds_n);
		(ss->*bp_n).tFFFFFFFC.u2 = (uint16) dx_n;
		(ss->*bp_n).tFFFFFFFA.u2 = (uint16) ax_n;
		Mem196[ds_n:11837:word16] = dx_n + 0x01;
		Mem197[ds_n:11835:word16] = 0x00;
		fn0800-87F8(ds_n);
		Eq_n sp_n;
		sp_n.u0 = <invalid>;
		Mem208[ss:sp_n + 0x02:word16] = Mem197[ds_n:0x29E5:word16];
		Mem211[ss:sp_n + 0x00:word16] = Mem208[ds_n:0x29E3:word16];
		Eq_n dx_ax_n = fn0800_AD2F(ds_n, (ss->*sp_n.u5).t0000.u1.u3);
		Mem223[ds_n:0x4664:word16] = SLICE(dx_ax_n, word16, 16);
		Mem224[ds_n:18018:word16] = SLICE(dx_ax_n, word16, 0);
		Mem227[ss:sp_n + 0x02:word16] = Mem224[ds_n:10721:word16];
		Mem230[ss:sp_n + 0x00:word16] = Mem227[ds_n:10719:word16];
		Eq_n dx_ax_n = fn0800_AD2F(ds_n, (ss->*sp_n.u5).t0000.u1.u3);
		Mem241[ds_n:0x4660:word16] = SLICE(dx_ax_n, word16, 16);
		Mem242[ds_n:18014:word16] = SLICE(dx_ax_n, word16, 0);
		Mem245[ss:sp_n + 0x02:word16] = Mem242[ds_n:10721:word16];
		Mem248[ss:sp_n + 0x00:word16] = Mem245[ds_n:10719:word16];
		Eq_n ax_n = Mem248[ds_n:0x2A21:word16];
		(ss->*((word32) sp_n - 2)).u3 = SLICE((uint32) ax_n + 0x524E4300, word16, 16);
		(ss->*((word32) sp_n - 4)).u3 = (word16) ax_n.u1 + 0x00004300;
		Eq_n ds_n = fn0800-409C(ds_n, ss->*((word32) sp_n - 4), ss->*((word32) sp_n - 2), ss->*sp_n.u4);
		Mem277[ss:sp_n + 0x02:word16] = Mem261[ds_n:10721:word16];
		Mem280[ss:sp_n + 0x00:word16] = Mem277[ds_n:10719:word16];
		Mem283[ss:sp_n + -2:word16] = Mem280[ds_n:0x4680:word16];
		Mem286[ss:sp_n + -4:word16] = Mem283[ds_n:0x467E:word16];
		Eq_n ds_n = fn0800-409C(ds_n, ss->*((word32) sp_n - 4), ss->*((word32) sp_n - 2), ss->*sp_n.u4);
		Mem301[ss:sp_n + 0x02:word16] = Mem286[ds_n:10721:word16];
		Mem304[ss:sp_n + 0x00:word16] = Mem301[ds_n:10719:word16];
		(ss->*((word32) sp_n - 2)).u0 = 0x00;
		(ss->*((word32) sp_n - 4)).u0 = 0x00;
		Eq_n ds_n = fn0800-409C(ds_n, ss->*((word32) sp_n - 4), ss->*((word32) sp_n - 2), ss->*sp_n.u4);
		Mem327[ss:sp_n + 0x02:word16] = Mem312[ds_n:10721:word16];
		Mem330[ss:sp_n + 0x00:word16] = Mem327[ds_n:10719:word16];
		(ss->*((word32) sp_n - 2)).u0 = 0x00;
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		Eq_n ds_n;
		fn0800-401E(ds_n, (ss->*sp_n.u5).t0002.u0, ss->*sp_n.u4, out cx_n, out dx_n, out bx_n, out ds_n);
		Mem351[ss:sp_n + 0x02:word16] = Mem336[ds_n:10721:word16];
		Mem354[ss:sp_n + 0x00:word16] = Mem351[ds_n:10719:word16];
		(ss->*((word32) sp_n - 2)).u0 = 0x00;
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		Eq_n ds_n;
		fn0800-401E(ds_n, (ss->*sp_n.u5).t0002.u0, ss->*sp_n.u4, out cx_n, out dx_n, out bx_n, out ds_n);
		Mem375[ss:sp_n + 0x02:word16] = Mem360[ds_n:10721:word16];
		Mem378[ss:sp_n + 0x00:word16] = Mem375[ds_n:10719:word16];
		(ss->*((word32) sp_n - 2)).u0 = 0x00;
		Eq_n cx_n;
		Eq_n dx_n;
		Eq_n bx_n;
		Eq_n ds_n;
		fn0800-401E(ds_n, (ss->*sp_n.u5).t0002.u0, ss->*sp_n.u4, out cx_n, out dx_n, out bx_n, out ds_n);
		(ss->*sp_n.u5).t0002.u1.u2 = (uint16) ds_n;
		(ss->*sp_n.u5).t0000.u1.u2 = (uint16) 0x2240;
		word16 di_n;
		fn0800_B2EF(cx_n, dx_n, bx_n, ds_n, ss->*sp_n.u4, out di_n);
		Mem413[ss:bp_n + -2:word16] = Mem402[ds_n:11855:word16];
		(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x01;
		Eq_n ax_n;
		ax_n.u0 = 0x01;
		if (Mem416[ds_n:0x2A1F:word16] == 0x00)
			ax_n.u0 = 0x00;
		(ss->*sp_n.u5).t0000.u1.u2 = (uint16) ax_n;
		fn0800-8465(ds_n, (ss->*sp_n.u5).t0000.u1.u2, (ss->*sp_n.u5).t0002.u1.u2);
		(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x01;
		Eq_n ax_n;
		ax_n.u0 = 0x01;
		if (Mem439[ds_n:11855:word16] == 0x00)
			ax_n.u0 = 0x00;
		(ss->*sp_n.u5).t0000.u1.u2 = (uint16) ax_n;
		fn0800-8465(ds_n, (ss->*sp_n.u5).t0000.u1.u2, (ss->*sp_n.u5).t0002.u1.u2);
		if (Mem450[ds_n:0x2A23:word16] != 0x01 && Mem450[ds_n:11855:word16] != 0x00)
		{
			(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x10;
			Mem469[ss:sp_n + 0x00:word16] = Mem466[ds_n:11855:word16];
			fn0800-8465(ds_n, (ss->*sp_n.u5).t0000.u1.u2, (ss->*sp_n.u5).t0002.u1.u2);
		}
		Eq_n ax_n = Mem480[ds_n:0x2A21:word16];
		byte ah_n = SLICE(ax_n, byte, 8);
		if (ax_n != 0x01)
		{
			if (ax_n == 0x02)
			{
				fn0800-7C78(ds_n, out ds_n);
				ah_n = 0x00;
			}
		}
		else
		{
			fn0800-7A02(ds_n, out ds_n);
			ah_n = 0x00;
		}
		byte Eq_n::* si_n = 18050;
		while (Mem514[ds_n:20098:word16] != 0x00)
		{
			(ss->*sp_n.u5).t0002.u1.u2 = (uint16) SEQ(ah_n, ds_n->*si_n);
			word16 di_n;
			fn0800-8624(ds_n, (ss->*sp_n.u5).t0002.u0, out di_n, out ds_n);
			Mem542[ds_n:20098:word16] = Mem527[ds_n:20098:word16] - 0x01;
			++si_n;
			ah_n = 0x00;
		}
		Mem550[ds_n:11855:word16] = Mem514[ss:bp_n + -2:word16];
		if (Mem550[ds_n:0x467E:ui32] - Mem550[ds_n:0x2A03:ui32] <u Mem550[ds_n:0x4E88:word32])
			Mem578[ds_n:0x4E88:ui32] = Mem574[ds_n:0x4E88:ui32] - (Mem550[ds_n:0x467E:ui32] - Mem550[ds_n:0x2A03:ui32]);
		else
		{
			Mem563[ds_n:20106:word16] = 0x00;
			Mem564[ds_n:0x4E88:word16] = 0x00;
		}
		if (Mem581[ds_n:0x2A21:word16] == 0x02)
			Mem589[ds_n:0x4E88:ui32] = Mem585[ds_n:0x4E88:ui32] + 0x02;
		Mem603[ss:sp_n + 0x02:word16] = Mem592[ds_n:10721:word16];
		Mem606[ss:sp_n + 0x00:word16] = Mem603[ds_n:10719:word16];
		int32 dx_ax_n = fn0800_AD2F(ds_n, (ss->*sp_n.u5).t0000.u1.u3) - Mem606[ds_n:18014:ui32];
		Mem621[ds_n:0x2A05:word16] = SLICE(dx_ax_n, word16, 16);
		Mem622[ds_n:0x2A03:word16] = SLICE(dx_ax_n, word16, 0);
		(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x00;
		Eq_n dx_n = Mem625[ds_n:18014:word16];
		Mem634[ss:sp_n + 0x00:word16] = SLICE(SEQ(Mem625[ds_n:0x4660:word16], dx_n) + 0x08, word16, 16);
		(ss->*((word32) sp_n - 2)).u3 = (word16) dx_n.u1 + 8;
		Mem639[ss:sp_n + -4:word16] = Mem636[ds_n:10721:word16];
		Mem642[ss:sp_n + -6:word16] = Mem639[ds_n:10719:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, ss->*((word32) sp_n - 6), ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0002.u1.u2, out cx_n);
		Mem656[ss:sp_n + 0x02:word16] = Mem642[ds_n:10721:word16];
		Mem659[ss:sp_n + 0x00:word16] = Mem656[ds_n:10719:word16];
		Eq_n dx_n = Mem659[ds_n:0x2A03:word16];
		Mem668[ss:sp_n + -2:word16] = SLICE(SEQ(Mem659[ds_n:0x2A05:word16], dx_n) - 0x12, word16, 16);
		ss->*((word32) sp_n - 4) = dx_n - 0x12;
		Eq_n ds_n = fn0800-409C(ds_n, ss->*((word32) sp_n - 4), ss->*((word32) sp_n - 2), ss->*sp_n.u4);
		Mem686[ss:sp_n + 0x02:word16] = Mem670[ds_n:10721:word16];
		Mem689[ss:sp_n + 0x00:word16] = Mem686[ds_n:10719:word16];
		Mem692[ss:sp_n + -2:word16] = Mem689[ds_n:11851:word16];
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		Eq_n ds_n;
		fn0800-401E(ds_n, (ss->*sp_n.u5).t0002.u0, ss->*sp_n.u4, out cx_n, out dx_n, out bx_n, out ds_n);
		Mem708[ss:sp_n + 0x02:word16] = Mem692[ds_n:10721:word16];
		Mem711[ss:sp_n + 0x00:word16] = Mem708[ds_n:10719:word16];
		Mem714[ss:sp_n + -2:word16] = Mem711[ds_n:11849:word16];
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		Eq_n ds_n;
		fn0800-401E(ds_n, (ss->*sp_n.u5).t0002.u0, ss->*sp_n.u4, out cx_n, out dx_n, out bx_n, out ds_n);
		Mem730[ss:sp_n + 0x02:word16] = Mem714[ds_n:10721:word16];
		Mem733[ss:sp_n + 0x00:word16] = Mem730[ds_n:10719:word16];
		Mem738[ss:sp_n + -2:word16] = CONVERT(Mem733[ds_n:0x4E88:byte], uint8, uint16);
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		word16 di_n;
		Eq_n ds_n;
		fn0800-4047(ds_n, ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0000.u1.u3, out cx_n, out dx_n, out bx_n, out di_n, out ds_n);
		Mem754[ss:sp_n + 0x02:word16] = Mem738[ds_n:10721:word16];
		Mem757[ss:sp_n + 0x00:word16] = Mem754[ds_n:10719:word16];
		Mem762[ss:sp_n + -2:word16] = CONVERT(Mem757[ds_n:0x29F7:byte], uint8, uint16);
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		word16 di_n;
		Eq_n ds_n;
		fn0800-4047(ds_n, ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0000.u1.u3, out cx_n, out dx_n, out bx_n, out di_n, out ds_n);
		(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x00;
		ui32 ax_dx_n = Mem777[ds_n:18014:ui32] + Mem777[ds_n:0x2A03:ui32];
		(ss->*sp_n.u5).t0000.u1.u2 = SLICE(ax_dx_n, word16, 16);
		ss->*((word32) sp_n - 2) = (word16) ax_dx_n;
		Mem791[ss:sp_n + -4:word16] = Mem788[ds_n:10721:word16];
		Mem794[ss:sp_n + -6:word16] = Mem791[ds_n:10719:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, ss->*((word32) sp_n - 6), ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0002.u1.u2, out cx_n);
		(ss->*sp_n.u5).t0002.u1.u2 = (uint16) 0x00;
		ui32 ax_dx_n = Mem808[ds_n:18018:ui32] + Mem808[ds_n:0x467E:ui32];
		(ss->*sp_n.u5).t0000.u1.u2 = SLICE(ax_dx_n, word16, 16);
		ss->*((word32) sp_n - 2) = (word16) ax_dx_n;
		Mem822[ss:sp_n + -4:word16] = Mem819[ds_n:0x29E5:word16];
		Mem825[ss:sp_n + -6:word16] = Mem822[ds_n:0x29E3:word16];
		word16 cx_n;
		fn0800_ACB3(ds_n, ss->*((word32) sp_n - 6), ss->*((word32) sp_n - 2), (ss->*sp_n.u5).t0002.u1.u2, out cx_n);
		(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFEC.u2;
		(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).tFFFFFFEA.u2;
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		Eq_n ds_n;
		fn0800-4346(ds_n, (ss->*sp_n.u5).t0002.u1.u2, out cx_n, out dx_n, out bx_n, out ds_n);
		(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFF0.u2;
		(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).tFFFFFFEE.u2;
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		Eq_n ds_n;
		fn0800-4346(ds_n, (ss->*sp_n.u5).t0002.u1.u2, out cx_n, out dx_n, out bx_n, out ds_n);
		(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFF4.u2;
		(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).tFFFFFFF2.u2;
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		Eq_n ds_n;
		fn0800-4346(ds_n, (ss->*sp_n.u5).t0002.u1.u2, out cx_n, out dx_n, out bx_n, out ds_n);
		(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFF8.u2;
		(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).tFFFFFFF6.u2;
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		Eq_n ds_n;
		fn0800-4346(ds_n, (ss->*sp_n.u5).t0002.u1.u2, out cx_n, out dx_n, out bx_n, out ds_n);
		(ss->*sp_n.u5).t0002.u1.u2 = (ss->*bp_n).tFFFFFFFC.u2;
		(ss->*sp_n.u5).t0000.u1.u2 = (ss->*bp_n).tFFFFFFFA.u2;
		Eq_n cx_n;
		Eq_n dx_n;
		Eq_n bx_n;
		fn0800-4346(ds_n, (ss->*sp_n.u5).t0002.u1.u2, out cx_n, out dx_n, out bx_n, out ds);
		(ss->*sp_n.u5).t0002.u1.u2 = (uint16) ds;
		(ss->*sp_n.u5).t0000.u1.u2 = (uint16) 0x223C;
		word16 di_n;
		fn0800_B2EF(cx_n, dx_n, bx_n, ds, ss->*sp_n.u4, out di_n);
		sp_n = (struct Eq_n Eq_n::*) &sp_n.u5->t0004.u0;
	}
	word16 bp_n = (ss->*bp_n).w0000;
	siOut.u2 = (ss->*sp_n).t0000.u2;
	dsOut = ds;
	return bp_n;
}

// 0800:7A02: Register byte fn0800-7A02(Register Eq_n ds, Register out Eq_n dsOut)
// Called from:
//      fn0800-75EA
byte fn0800-7A02(Eq_n ds, union Eq_n & dsOut)
{
	word16 di_n;
	word16 cx_n;
	word32 dwLoc06_n = Mem13[ds:18018:word32];
	Eq_n ax_n;
	while (true)
	{
		ax_n = Mem20[ds:18044:word16];
		Eq_n dx_n = Mem20[ds:0x467A:word16];
		if (ax_n >=u Mem20[ds:0x4680:word16] && (ax_n != Mem20[ds:0x4680:word16] || dx_n >=u Mem20[ds:0x467E:word16]))
			break;
		fn0800-43D4(10319, ds, 0x10);
		fn0800-43D4(10127, ds, 0x10);
		fn0800-43D4(10511, ds, 0x10);
		ds = fn0800-7FDC(ds);
		word16 cx_n;
		fn0800_ACB3(ds, Mem192[ds:0x29E3:word32], dwLoc06_n, 0x00, out cx_n);
		fn0800-441C(ds, SEQ(ds, 10511), 0x10);
		fn0800-441C(ds, SEQ(ds, 10319), 0x10);
		fn0800-441C(ds, SEQ(ds, 10127), 0x10);
		fn0800-83A1(ds, SEQ(ds, 10511), 0x10);
		fn0800-83A1(ds, SEQ(ds, 10319), 0x10);
		fn0800-83A1(ds, SEQ(ds, 10127), 0x10);
		fn0800-8489(ds, Mem324[ds:0x466A:word16], 0x10);
		while (true)
		{
			Eq_n ax_n = Mem336[ds:0x466A:word16];
			cu16 dx_n = Mem336[ds:0x466C:word16];
			Mem344[ds:0x466A:ui32] = Mem340[ds:0x466A:ui32] - 0x01;
			if ((ax_n | dx_n) == 0x00)
				break;
			Eq_n ax_n = fn0800-3E27(ds, Mem344[ds:10715:word32], out cx_n, out di_n, out ds);
			Mem440[ds:11847:word16] = ax_n;
			Mem446[ds:0x467A:ui32] = Mem442[ds:0x467A:ui32] + CONVERT(ax_n, uint16, uint32);
			fn0800-8407(ds, Mem452[ds:11847:word16], SEQ(ds, 10511));
			if (Mem455[ds:11847:word16] != 0x00)
			{
				if (Mem455[ds:11845:word16] != 0x00)
				{
					while (true)
					{
						Eq_n ax_n = Mem516[ds:11847:word16];
						Mem519[ds:11847:word16] = Mem516[ds:11847:word16] - 0x01;
						if (ax_n == 0x00)
							break;
						Eq_n ds_n;
						Mem541[ds_n:Mem519[ds_n:20098:word16] + 18050:byte] = fn0800-8359(ds, out ds_n) ^ Mem519[ds_n:11855:byte];
						Mem543[ds_n:20098:word16] = Mem541[ds_n:20098:word16] + 0x01;
						ds = ds_n;
					}
				}
				else
				{
					while (true)
					{
						Eq_n ax_n = Mem471[ds:11847:word16];
						Mem474[ds:11847:word16] = Mem471[ds:11847:word16] - 0x01;
						if (ax_n == 0x00)
							break;
						Eq_n ds_n;
						word16 di_n;
						fn0800-8624(ds_n, fn0800-8359(ds, out ds_n) ^ Mem474[ds_n:11855:byte], out di_n, out ds);
					}
				}
				if ((Mem546[ds:11855:word16] & 0x01) != 0x00)
					Mem560[ds:11855:word16] = Mem546[ds:11855:word16] >>u 0x01 | 0x8000;
				else
					Mem552[ds:11855:word16] = Mem546[ds:11855:word16] >>u 0x01;
			}
			if ((Mem562[ds:0x466A:word16] | Mem562[ds:0x466C:word16]) != 0x00)
			{
				Eq_n ds_n;
				word16 cx_n;
				word16 di_n;
				Mem593[ds_n:11817:word16] = fn0800-3E27(ds, Mem562[ds:10715:word32], out cx_n, out di_n, out ds_n);
				word16 cx_n;
				word16 di_n;
				Mem613[ds:11819:word16] = fn0800-3E27(ds_n, Mem593[ds_n:10715:word32], out cx_n, out di_n, out ds);
				fn0800-8407(ds, Mem618[ds:11819:word16], SEQ(ds, 10319));
				fn0800-8407(ds, Mem637[ds:11817:word16], SEQ(ds, 10127));
				Mem652[ds:11817:word16] = Mem640[ds:11817:word16] + 0x02;
				Mem659[ds:0x467A:ui32] = Mem655[ds:0x467A:ui32] + CONVERT(Mem652[ds:11817:word16], uint16, uint32);
				while (true)
				{
					Eq_n ax_n = Mem662[ds:11817:word16];
					Mem665[ds:11817:word16] = Mem662[ds:11817:word16] - 0x01;
					if (ax_n == 0x00)
						break;
					fn0800-8359(ds, out ds);
				}
			}
		}
		if (Mem344[ds:11845:word16] == 0x00)
		{
			byte Eq_n::* si_n = 18050;
			while (Mem357[ds:20098:word16] != 0x00)
			{
				word16 di_n;
				fn0800-8624(ds, ds->*si_n, out di_n, out ds);
				Mem385[ds:20098:word16] = Mem370[ds:20098:word16] - 0x01;
				++si_n;
			}
		}
		Mem394[ds:0x29F7:ui32] = Mem390[ds:0x29F7:ui32] + 0x01;
		dwLoc06_n = fn0800_AD2F(ds, Mem394[ds:0x29E3:word32]);
	}
	Mem33[ds:11843:word16] = Mem20[ds:11843:word16] >>u 0x10 - Mem20[ds:11845:byte];
	Eq_n ax_n = ax_n;
	if (Mem33[ds:11845:word16] != 0x00 || Mem33[ds:20098:word16] != 0x00)
	{
		word16 di_n;
		ax_n = CONVERT(fn0800-8624(ds, Mem33[ds:11843:byte], out di_n, out ds), uint8, uint16);
	}
	if (Mem67[ds:11845:word16] >u 0x08 || Mem67[ds:20098:word16] != 0x00)
	{
		word16 di_n;
		ax_n = CONVERT(fn0800-8624(ds, SLICE(Mem67[ds:11843:word16] >>u 0x08, byte, 0), out di_n, out ds), uint8, uint16);
	}
	dsOut = ds;
	return SLICE(ax_n, byte, 8);
}

// 0800:7C78: Register byte fn0800-7C78(Register Eq_n ds, Register out Eq_n dsOut)
// Called from:
//      fn0800-75EA
byte fn0800-7C78(Eq_n ds, union Eq_n & dsOut)
{
	word16 di_n;
	word16 cx_n;
	word32 dwLoc06_n = Mem13[ds:18018:word32];
	Eq_n ax_n;
	while (true)
	{
		ax_n = Mem20[ds:18044:word16];
		Eq_n dx_n = Mem20[ds:0x467A:word16];
		if (ax_n >=u Mem20[ds:0x4680:word16] && (ax_n != Mem20[ds:0x4680:word16] || dx_n >=u Mem20[ds:0x467E:word16]))
			break;
		Eq_n ds_n = fn0800-7FDC(ds);
		word16 cx_n;
		fn0800_ACB3(ds_n, Mem105[ds_n:0x29E3:word32], dwLoc06_n, 0x00, out cx_n);
		while (true)
		{
			Eq_n ax_n = Mem125[ds_n:0x466A:word16];
			cu16 dx_n = Mem125[ds_n:0x466C:word16];
			Mem133[ds_n:0x466A:ui32] = Mem129[ds_n:0x466A:ui32] - 0x01;
			if ((ax_n | dx_n) == 0x00)
				break;
			Eq_n ax_n = fn0800-3E27(ds_n, Mem133[ds_n:10715:word32], out cx_n, out di_n, out ds_n);
			Mem310[ds_n:11847:word16] = ax_n;
			Mem316[ds_n:0x467A:ui32] = Mem312[ds_n:0x467A:ui32] + CONVERT(ax_n, uint16, uint32);
			fn0800-7EAF(ds_n, ax_n);
			if ((Mem319[ds_n:0x466A:word16] | Mem319[ds_n:0x466C:word16]) != 0x00)
			{
				Eq_n ds_n;
				word16 cx_n;
				word16 di_n;
				Mem350[ds_n:11817:word16] = fn0800-3E27(ds_n, Mem319[ds_n:10715:word32], out cx_n, out di_n, out ds_n);
				Eq_n ds_n;
				word16 cx_n;
				word16 di_n;
				Mem369[ds_n:11819:word16] = fn0800-3E27(ds_n, Mem350[ds_n:10715:word32], out cx_n, out di_n, out ds_n);
				if (Mem369[ds_n:11817:word16] == 0x00)
				{
					fn0800-854B(ds_n, 0x06, 0x03);
					fn0800-8600(ds_n, Mem517[ds_n:11819:byte], out ds_n);
				}
				else if (Mem369[ds_n:11817:word16] <u 0x07)
				{
					Eq_n bx_n = Mem369[ds_n:11817:word16];
					fn0800-854B(ds_n, (uint16) (ds_n->*((word32) bx_n + 8660)), (uint16) (ds_n->*((word32) bx_n + 8667)));
					Eq_n bx_n = Mem460[ds_n:11819:word16];
					fn0800-854B(ds_n, (uint16) (ds_n->*((word16) (bx_n >> 0x08) + 0x000021E2)), (uint16) (ds_n->*((word16) (bx_n >> 0x08) + 0x000021F2)));
					fn0800-8600(ds_n, Mem482[ds_n:11819:byte], out ds_n);
				}
				else
				{
					fn0800-854B(ds_n, 0x0F, 0x04);
					Eq_n ds_n;
					fn0800-8600(ds_n, Mem379[ds_n:11817:byte] - 0x06, out ds_n);
					Eq_n bx_n = Mem393[ds_n:11819:word16];
					fn0800-854B(ds_n, (uint16) (ds_n->*((word16) (bx_n >> 0x08) + 0x000021E2)), (uint16) (ds_n->*((word16) (bx_n >> 0x08) + 0x000021F2)));
					fn0800-8600(ds_n, Mem420[ds_n:11819:byte], out ds_n);
				}
				Mem547[ds_n:11817:word16] = Mem545[ds_n:11817:word16] + 0x02;
				Mem554[ds_n:0x467A:ui32] = Mem550[ds_n:0x467A:ui32] + CONVERT(Mem547[ds_n:11817:word16], uint16, uint32);
				while (true)
				{
					Eq_n ax_n = Mem557[ds_n:11817:word16];
					Mem560[ds_n:11817:word16] = Mem557[ds_n:11817:word16] - 0x01;
					if (ax_n == 0x00)
						break;
					fn0800-8359(ds_n, out ds_n);
				}
			}
		}
		fn0800-854B(ds_n, 0x0F, 0x04);
		fn0800-8600(ds_n, 0x00, out ds);
		if (Mem159[ds:0x467A:word32] <u Mem159[ds:0x467E:word32])
			fn0800-854B(ds, 0x01, 0x01);
		else
			fn0800-854B(ds, 0x00, 0x01);
		if (Mem216[ds:11845:word16] == 0x00)
		{
			byte Eq_n::* si_n = 18050;
			while (Mem224[ds:20098:word16] != 0x00)
			{
				word16 di_n;
				fn0800-8624(ds, ds->*si_n, out di_n, out ds);
				Mem252[ds:20098:word16] = Mem237[ds:20098:word16] - 0x01;
				++si_n;
			}
		}
		Mem261[ds:0x29F7:ui32] = Mem257[ds:0x29F7:ui32] + 0x01;
		dwLoc06_n = fn0800_AD2F(ds, Mem261[ds:0x29E3:word32]);
	}
	Mem33[ds:11843:word16] = Mem20[ds:11843:word16] << 0x08 - Mem20[ds:11845:byte];
	Eq_n ax_n = ax_n;
	if (Mem33[ds:11845:word16] != 0x00 || Mem33[ds:20098:word16] != 0x00)
	{
		word16 di_n;
		ax_n = CONVERT(fn0800-8624(ds, Mem33[ds:11843:byte], out di_n, out ds), uint8, uint16);
	}
	dsOut = ds;
	return SLICE(ax_n, byte, 8);
}

// 0800:7EAF: void fn0800-7EAF(Register Eq_n ds, Stack Eq_n wArg02)
// Called from:
//      fn0800-7C78
void fn0800-7EAF(Eq_n ds, Eq_n wArg02)
{
	Eq_n si_n = wArg02;
	while (true)
	{
		Eq_n si_n = si_n;
		if (si_n == 0x00)
			break;
		if (si_n < 0x0C)
		{
			while (true)
			{
				si_n = si_n;
				if (si_n == 0x00)
					break;
				fn0800-854B(ds, 0x00, 0x01);
				Eq_n ds_n;
				fn0800-8600(ds_n, fn0800-8359(ds, out ds_n) ^ Mem292[ds_n:11855:byte], out ds);
				if ((Mem321[ds:11855:word16] & 0x01) != 0x00)
					Mem347[ds:11855:word16] = Mem321[ds:11855:word16] >>u 0x01 | 0x8000;
				else
					Mem339[ds:11855:word16] = Mem321[ds:11855:word16] >>u 0x01;
				--si_n;
			}
		}
		else
		{
			while ((si_n & 0x03) != 0x00)
			{
				fn0800-854B(ds, 0x00, 0x01);
				Eq_n ds_n;
				fn0800-8600(ds_n, fn0800-8359(ds, out ds_n) ^ Mem48[ds_n:11855:byte], out ds);
				if ((Mem77[ds:11855:word16] & 0x01) != 0x00)
					Mem103[ds:11855:word16] = Mem77[ds:11855:word16] >>u 0x01 | 0x8000;
				else
					Mem95[ds:11855:word16] = Mem77[ds:11855:word16] >>u 0x01;
				--si_n;
			}
			fn0800-854B(ds, 0x17, 0x05);
			if (si_n >= 0x48)
			{
				fn0800-854B(ds, 0x0F, 0x04);
				word16 di_n = 0x00;
				while (di_n != 0x48)
				{
					Eq_n ds_n;
					di_n = fn0800-8600(ds_n, fn0800-8359(ds, out ds_n) ^ Mem233[ds_n:11855:byte], out ds) + 0x01;
				}
				if ((Mem233[ds:11855:word16] & 0x01) != 0x00)
					Mem271[ds:11855:word16] = Mem233[ds:11855:word16] >>u 0x01 | 0x8000;
				else
					Mem263[ds:11855:word16] = Mem233[ds:11855:word16] >>u 0x01;
				si_n = si_n - 0x48;
			}
			else
			{
				fn0800-854B(ds, si_n - 0x0C >> 0x02, 0x04);
				while (true)
				{
					si_n = si_n;
					if (si_n == 0x00)
						break;
					Eq_n ds_n;
					fn0800-8600(ds_n, fn0800-8359(ds, out ds_n) ^ Mem160[ds_n:11855:byte], out ds);
					--si_n;
				}
				if ((Mem160[ds:11855:word16] & 0x01) != 0x00)
					Mem198[ds:11855:word16] = Mem160[ds:11855:word16] >>u 0x01 | 0x8000;
				else
					Mem190[ds:11855:word16] = Mem160[ds:11855:word16] >>u 0x01;
			}
		}
	}
}

// 0800:7FDC: Register Eq_n fn0800-7FDC(Register Eq_n ds)
// Called from:
//      fn0800-7A02
//      fn0800-7C78
Eq_n fn0800-7FDC(Eq_n ds)
{
	Eq_n bx_n;
	Eq_n cx_n;
	byte ch_n;
	mp16 fp;
	Mem11[ds:0x466C:word16] = 0x00;
	Mem12[ds:0x466A:word16] = 0x00;
	Mem13[ds:11847:word16] = 0x00;
	Eq_n dx_n = Mem13[ds:0x2A0B:word16];
	Mem16[ds:0x4670:word16] = Mem13[ds:0x2A0D:word16];
	Mem17[ds:0x466E:word16] = dx_n;
	word16 cx_n;
	fn0800_ACB3(ds, Mem35[ds:0x29E3:word32], Mem20[ds:18018:ui32] + Mem20[ds:0x467A:ui32] + Mem20[ds:0x4672:ui32], 0x00, out cx_n);
	word16 cx_n;
	fn0800_ACB3(ds, Mem62[ds:10715:word32], 0x00, 0x00, out cx_n);
	struct Eq_n Eq_n::* sp_n = fp - 0x06;
	selector ss;
	while ((Mem82[ds:0x4676:word16] | Mem82[ds:18040:word16]) != 0x00 || (Mem82[ds:0x4672:word16] | Mem82[ds:0x4674:word16]) != 0x00)
	{
		Eq_n ax_dx_n = 0xFFFF - CONVERT(Mem82[ds:11825:word16], uint16, uint32) - Mem82[ds:0x4672:ui32];
		Eq_n dwLoc06_n = ax_dx_n;
		if (Mem112[ds:0x4676:word32] <u ax_dx_n)
			dwLoc06_n = Mem112[ds:0x4676:word32];
		Eq_n dx_n = Mem129[ds:11889:word16] + Mem129[ds:11825:word16];
		Mem133[ds:11887:word16] = Mem129[ds:11891:word16];
		Mem134[ds:11885:word16] = dx_n;
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		Mem142[ss:sp_n + 0x00:word16] = Mem134[ds:0x29E5:word16];
		Mem145[ss:sp_n + -2:word16] = Mem142[ds:0x29E3:word16];
		(ss->*sp_n).tFFFFFFFC.u2 = SLICE(dwLoc06_n, word16, 16);
		(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (word16) dwLoc06_n;
		Eq_n ax_n = Mem152[ds:11885:word16] + Mem152[ds:0x4672:word16];
		Mem158[ss:sp_n + -8:word16] = Mem152[ds:11891:word16];
		(ss->*sp_n).tFFFFFFF6.u2 = (uint16) ax_n;
		word16 si_n;
		word16 di_n;
		fn0800-4110(ds, (ss->*sp_n).tFFFFFFF6.u3, (ss->*sp_n).tFFFFFFFA.u2, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u3, out si_n, out di_n, out ds);
		Mem181[ds:0x4676:ui32] = Mem177[ds:0x4676:ui32] - dwLoc06_n;
		Mem187[ds:0x4672:ui32] = Mem183[ds:0x4672:ui32] + dwLoc06_n;
		Eq_n ax_n = Mem187[ds:11887:word16];
		cup16 dx_n = Mem187[ds:11885:word16] + Mem187[ds:0x4672:word16];
		Mem191[ds:11879:word16] = ax_n;
		Mem192[ds:11877:word16] = dx_n;
		Mem193[ds:11883:word16] = ax_n;
		Mem194[ds:11881:word16] = dx_n;
		Eq_n sp_n;
		sp_n.u3 = (char *) &sp_n->t0000 + 2;
		cu16 ax_n = Mem194[ds:0x4670:word16];
		Eq_n dx_n = Mem194[ds:0x466E:word16];
		if (ax_n <=u Mem194[ds:0x4674:word16] && (ax_n <u Mem194[ds:0x4674:word16] || dx_n <u Mem194[ds:0x4672:word16]))
		{
			cup16 dx_n = Mem194[ds:11885:word16] + Mem194[ds:0x466E:word16];
			Mem208[ds:11879:word16] = Mem194[ds:11887:word16];
			Mem209[ds:11877:word16] = dx_n;
		}
		Eq_n sp_n;
		while (Mem211[ds:11877:word16] - 0x01 >u Mem211[ds:11885:word16] && (Mem211[ds:0x466C:word16] <u 0x00 || Mem211[ds:0x466C:word16] == 0x00 && Mem211[ds:0x466A:word16] <u ~0x01))
		{
			fn0800-8832(ds);
			if (Mem211[ds:11817:word16] >=u 0x02)
			{
				if (Mem211[ds:11885:word16] + Mem211[ds:11817:word16] >u Mem211[ds:11877:word16])
				{
					if ((Mem211[ds:0x466A:word16] | Mem211[ds:0x466C:word16]) != 0x00)
						break;
					Mem276[ds:11817:word16] = Mem211[ds:11877:word16] - Mem211[ds:11885:word16];
				}
				struct Eq_n Eq_n::* sp_n = sp_n - 2;
				(ss->*sp_n).t0000.u2 = (uint16) ds;
				(ss->*sp_n).tFFFFFFFE.u0 = 10511;
				Mem287[ss:sp_n + -4:word16] = Mem284[ds:11847:word16];
				Eq_n ds_n = fn0800-831D(ds, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u1);
				(ss->*sp_n).t0000.u2 = (uint16) ds_n;
				(ss->*sp_n).tFFFFFFFE.u0 = 10127;
				Mem309[ss:sp_n + -4:word16] = Mem304[ds_n:11817:word16] - 0x02;
				Eq_n ds_n = fn0800-831D(ds_n, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u1);
				(ss->*sp_n).t0000.u2 = (uint16) ds_n;
				(ss->*sp_n).tFFFFFFFE.u0 = 10319;
				Mem332[ss:sp_n + -4:word16] = Mem327[ds_n:11819:word16] - 0x01;
				ds = fn0800-831D(ds_n, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u1);
				Mem348[ss:sp_n + 0x00:word16] = Mem332[ds:11817:word16];
				fn0800-89A8(ds, (ss->*sp_n).t0000.u2);
				Mem365[ds:0x466A:ui32] = Mem361[ds:0x466A:ui32] + 0x01;
				Mem366[ds:11847:word16] = 0x00;
				Mem369[ds:18012:word16] = Mem366[ds:18012:word16] + Mem366[ds:11817:word16];
			}
			else
			{
				union Eq_n Eq_n::* sp_n = sp_n - 2;
				(ss->*sp_n).u2 = (uint16) 0x01;
				fn0800-89A8(ds, (ss->*sp_n).u2);
				Mem255[ds:11847:word16] = Mem241[ds:11847:word16] + 0x01;
				Mem257[ds:18012:word16] = Mem255[ds:18012:word16] + 0x01;
			}
			sp_n = sp_n;
			sp_n = sp_n;
			if (Mem372[ds:18012:word16] >=u 0x0400)
			{
				Mem381[ds:0x4666:ui32] = Mem377[ds:0x4666:ui32] + CONVERT(Mem372[ds:18012:word16], uint16, uint32);
				struct Eq_n Eq_n::* sp_n = sp_n - 2;
				Mem386[ss:sp_n + 0x00:word16] = Mem381[ds:0x4680:word16];
				Mem389[ss:sp_n + -2:word16] = Mem386[ds:0x467E:word16];
				ui32 dx_ax_n = fn0800-8F18(99, Mem389[ds:0x4668:word16], 0x00, Mem389[ds:0x4666:word16], out ch_n);
				(ss->*sp_n).tFFFFFFFC.u2 = SLICE(dx_ax_n, word16, 16);
				(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (word16) dx_ax_n;
				Eq_n dx_ax_n = fn0800-8BC2((ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3, out cx_n, out bx_n);
				Eq_n sp_n;
				sp_n.u0 = <invalid>;
				Eq_n dx_n;
				dx_n.u3 = SLICE(dx_ax_n, word16, 16);
				ss->*((word32) sp_n - 2) = dx_n;
				ss->*((word32) sp_n - 4) = (word16) dx_ax_n;
				ss->*((word32) sp_n - 6) = ds;
				(ss->*((word32) sp_n - 8)).u0 = 0x2244;
				word16 di_n;
				fn0800_B2EF(cx_n, dx_n, bx_n, ds, ss->*((word32) sp_n - 8), out di_n);
				Mem438[ds:18012:word16] = 0x00;
				sp_n = sp_n;
			}
		}
		Eq_n ax_n = Mem211[ds:11881:word16] - Mem211[ds:11885:word16];
		Mem447[ds:0x4674:word16] = 0x00;
		Mem448[ds:0x4672:word16] = ax_n;
		ui32 dx_ax_n = CONVERT(Mem448[ds:11885:word16] - Mem448[ds:11889:word16] - Mem448[ds:11825:word16], word16, uint32);
		Eq_n ax_n = Mem467[ds:11889:word16] + SLICE(dx_ax_n, word16, 0);
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		Mem481[ss:sp_n + 0x00:word16] = Mem467[ds:11885:word16] - ax_n + Mem467[ds:0x4672:word16];
		Mem484[ss:sp_n + -2:word16] = Mem481[ds:11891:word16];
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) ax_n;
		Mem489[ss:sp_n + -6:word16] = Mem486[ds:11891:word16];
		Mem492[ss:sp_n + -8:word16] = Mem489[ds:11889:word16];
		fn0800_B0F3((ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3, (ss->*sp_n).t0000.u2);
		sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0000 + 2);
		if (Mem492[ds:11877:word16] <u Mem492[ds:11881:word16])
			break;
		cup16 dx_n = Mem492[ds:11877:word16];
		if (Mem492[ds:11879:word16] == Mem492[ds:11883:word16] && (dx_n == Mem492[ds:11881:word16] && (Mem492[ds:0x4676:word16] | Mem492[ds:18040:word16]) == 0x00) || Mem492[ds:0x466C:word16] == 0x00 && Mem492[ds:0x466A:word16] == ~0x01)
			break;
		Mem631[ds:0x466E:ui32] = Mem627[ds:0x466E:ui32] - dx_ax_n;
	}
	cup16 dx_n = Mem527[ds:11877:word16];
	if (Mem527[ds:11879:word16] == Mem527[ds:11883:word16] && (dx_n == Mem527[ds:11881:word16] && ((Mem527[ds:0x4676:word16] | Mem527[ds:18040:word16]) == 0x00 && (Mem527[ds:0x466C:word16] != 0x00 || Mem527[ds:0x466A:word16] != ~0x01))))
		Mem549[ds:11847:word16] = Mem527[ds:11847:word16] + Mem527[ds:0x4672:word16];
	struct Eq_n Eq_n::* sp_n = sp_n - 2;
	(ss->*sp_n).t0000.u2 = (uint16) ds;
	(ss->*sp_n).tFFFFFFFE.u0 = 10511;
	Mem566[ss:sp_n + -4:word16] = Mem563[ds:11847:word16];
	Eq_n ds_n = fn0800-831D(ds, (ss->*sp_n).tFFFFFFFC.u2, (ss->*sp_n).tFFFFFFFE.u1);
	Mem584[ds_n:0x466A:ui32] = Mem580[ds_n:0x466A:ui32] + 0x01;
	(ss->*sp_n).t0000.u2 = (uint16) 0x00;
	(ss->*sp_n).tFFFFFFFE.u0 = 0x00;
	(ss->*sp_n).tFFFFFFFC.u2 = (uint16) 0x00;
	Mem597[ss:sp_n + -6:word16] = Mem594[ds_n:10717:word16];
	Mem600[ss:sp_n + -8:word16] = Mem597[ds_n:10715:word16];
	word16 cx_n;
	fn0800_ACB3(ds_n, (ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3, (ss->*sp_n).t0000.u2, out cx_n);
	return ds_n;
}

// 0800:831D: Register Eq_n fn0800-831D(Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n ptrArg04)
// Called from:
//      fn0800-7FDC
Eq_n fn0800-831D(Eq_n ds, Eq_n wArg02, Eq_n ptrArg04)
{
	Eq_n ax_n;
	if (wArg02 > 0x01)
		ax_n = fn0800-0C08(wArg02);
	else
		ax_n = wArg02;
	struct Eq_n * es_n = SLICE(ptrArg04, selector, 16);
	ui32 Eq_n::* bx_n = (word16) ptrArg04 + ax_n *s16 0x0C;
	++es_n->*bx_n;
	word16 cx_n;
	word16 dx_n;
	word16 bx_n;
	Eq_n ds_n;
	fn0800-401E(ds, (byte) wArg02, Mem44[ds:10715:word32], out cx_n, out dx_n, out bx_n, out ds_n);
	return ds_n;
}

// 0800:8359: Register byte fn0800-8359(Register Eq_n ds, Register out (ptr16 Eq_n) dsOut)
// Called from:
//      fn0800-7A02
//      fn0800-7C78
//      fn0800-7EAF
byte fn0800-8359(Eq_n ds, struct Eq_n & dsOut)
{
	struct Eq_n * ds_n;
	word16 di_n;
	byte ch_n;
	byte al_n = SLICE(fn0800-3DCF(ds, Mem7[ds:0x29E3:word32], out ch_n, out di_n, out ds_n), byte, 0);
	ds_n->t2E4B = ds_n->a2A29[0][(uint16) (ds_n->t2E4B ^ al_n) & 0xFF] ^ ds_n->t2E4B >> 0x08;
	++ds_n->dw29FF;
	dsOut = ds_n;
	return al_n;
}

// 0800:83A1: void fn0800-83A1(Register Eq_n ds, Stack segptr32 ptrArg02, Stack Eq_n wArg06)
// Called from:
//      fn0800-7A02
void fn0800-83A1(Eq_n ds, segptr32 ptrArg02, Eq_n wArg06)
{
	struct Eq_n * psegArg04_n = SLICE(ptrArg02, selector, 16);
	Eq_n di_n = wArg06;
	Eq_n si_n = wArg06;
	word16 wArg02_n;
	while (true)
	{
		wArg02_n = (word16) ptrArg02;
		--si_n;
		if (si_n == 0x00 || ((char *) ((word16) ptrArg02) + si_n *s16 0x0C)[0x0A] != 0x00)
			break;
		--di_n;
	}
	fn0800-8489(ds, di_n, 0x05);
	Eq_n si_n;
	si_n.u0 = 0x00;
	struct Eq_n Eq_n::* wLoc04_n = wArg02_n + 0x0A;
	if (di_n > 0x00)
	{
		do
		{
			fn0800-8489(ds, (psegArg04_n->*wLoc04_n).w0000, 0x04);
			++wLoc04_n;
			si_n.u3 = &si_n.u5->b0001;
		} while (si_n < di_n);
	}
}

// 0800:8407: void fn0800-8407(Register Eq_n ds, Stack Eq_n wArg02, Stack segptr32 ptrArg04)
// Called from:
//      fn0800-7A02
void fn0800-8407(Eq_n ds, Eq_n wArg02, segptr32 ptrArg04)
{
	Eq_n ax_n;
	if (wArg02 > 0x01)
		ax_n = fn0800-0C08(wArg02);
	else
		ax_n = wArg02;
	struct Eq_n * es_n = SLICE(ptrArg04, selector, 16);
	struct Eq_n Eq_n::* bx_n = (word16) ptrArg04 + ax_n *s16 0x0C;
	fn0800-8489(ds, (es_n->*bx_n).t0006.u2, (es_n->*bx_n).t000A.u2);
	byte bLoc04_n = (byte) ax_n;
	if (ax_n > 0x01)
		fn0800-8489(ds, wArg02 - (0x01 << bLoc04_n - 0x01), ax_n - 0x01);
}

// 0800:8465: void fn0800-8465(Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n wArg04)
// Called from:
//      fn0800-75EA
void fn0800-8465(Eq_n ds, Eq_n wArg02, Eq_n wArg04)
{
	if (Mem7[ds:0x2A21:word16] != 0x02)
		fn0800-8489(ds, wArg02, wArg04);
	else
		fn0800-854B(ds, wArg02, wArg04);
}

// 0800:8489: void fn0800-8489(Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n wArg04)
// Called from:
//      fn0800-7A02
//      fn0800-83A1
//      fn0800-8407
//      fn0800-8465
void fn0800-8489(Eq_n ds, Eq_n wArg02, Eq_n wArg04)
{
	Eq_n di_n = wArg02;
	while (true)
	{
		--wArg04;
		if (wArg04 == 0x00)
			break;
		Mem36[ds:11843:word16] = Mem21[ds:11843:word16] >>u 0x01;
		if ((di_n & 0x01) != 0x00)
			Mem43[ds:11843:word16] = Mem36[ds:11843:word16] | 0x8000;
		Mem52[ds:11845:word16] = Mem50[ds:11845:word16] + 0x01;
		di_n >>= 0x01;
		if (Mem52[ds:11845:word16] == 0x10)
		{
			word16 di_n;
			Eq_n ds_n;
			fn0800-8624(ds, Mem52[ds:11843:byte], out di_n, out ds_n);
			fn0800-8624(ds_n, SLICE(Mem62[ds_n:11843:word16] >>u 0x08, byte, 0), out di_n, out ds);
			byte Eq_n::* si_n = 18050;
			while (Mem98[ds:20098:word16] != 0x00)
			{
				fn0800-8624(ds, ds->*si_n, out di_n, out ds);
				Mem126[ds:20098:word16] = Mem111[ds:20098:word16] - 0x01;
				++si_n;
			}
			if (Mem98[ds:0x29FF:word32] >u Mem98[ds:0x2A03:word32] && Mem98[ds:0x29FF:ui32] - Mem98[ds:0x2A03:ui32] >u Mem98[ds:0x4E88:word32])
			{
				ui32 ax_dx_n = Mem98[ds:0x29FF:ui32] - Mem98[ds:0x2A03:ui32];
				Mem157[ds:20106:word16] = SLICE(ax_dx_n, word16, 16);
				Mem158[ds:0x4E88:word16] = SLICE(ax_dx_n, word16, 0);
			}
			Mem164[ds:11845:word16] = 0x00;
			Mem165[ds:11843:word16] = 0x00;
		}
	}
}

// 0800:854B: void fn0800-854B(Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n wArg04)
// Called from:
//      fn0800-7C78
//      fn0800-7EAF
//      fn0800-8465
void fn0800-854B(Eq_n ds, Eq_n wArg02, Eq_n wArg04)
{
	byte bArg04 = (byte) wArg04;
	uint16 di_n = 0x01 << bArg04 - 0x01;
	Eq_n wArg04_n = wArg04;
	while (true)
	{
		--wArg04_n;
		if (wArg04_n == 0x00)
			break;
		Mem40[ds:11843:word16] = Mem25[ds:11843:word16] << 0x01;
		if ((wArg02 & di_n) != 0x00)
			Mem47[ds:11843:word16] = Mem40[ds:11843:word16] + 0x01;
		Mem54[ds:11845:word16] = Mem52[ds:11845:word16] + 0x01;
		di_n >>= 0x01;
		if (Mem54[ds:11845:word16] == 0x08)
		{
			fn0800-8624(ds, Mem54[ds:11843:byte], out di_n, out ds);
			byte Eq_n::* si_n = 18050;
			while (Mem82[ds:20098:word16] != 0x00)
			{
				fn0800-8624(ds, ds->*si_n, out di_n, out ds);
				Mem110[ds:20098:word16] = Mem95[ds:20098:word16] - 0x01;
				++si_n;
			}
			if (Mem82[ds:0x29FF:word32] >u Mem82[ds:0x2A03:word32] && Mem82[ds:0x29FF:ui32] - Mem82[ds:0x2A03:ui32] >u Mem82[ds:0x4E88:word32])
			{
				ui32 ax_dx_n = Mem82[ds:0x29FF:ui32] - Mem82[ds:0x2A03:ui32];
				Mem141[ds:20106:word16] = SLICE(ax_dx_n, word16, 16);
				Mem142[ds:0x4E88:word16] = SLICE(ax_dx_n, word16, 0);
			}
			Mem148[ds:11845:word16] = 0x00;
			Mem149[ds:11843:word16] = 0x00;
		}
	}
}

// 0800:8600: Register word16 fn0800-8600(Register Eq_n ds, Stack Eq_n bArg02, Register out Eq_n dsOut)
// Called from:
//      fn0800-7C78
//      fn0800-7EAF
word16 fn0800-8600(Eq_n ds, Eq_n bArg02, union Eq_n & dsOut)
{
	if (Mem7[ds:11845:word16] == 0x00)
	{
		word16 di_n;
		Eq_n ds_n;
		fn0800-8624(ds, bArg02, out di_n, out ds_n);
		dsOut = ds_n;
		return di_n;
	}
	else
	{
		Mem33[ds:Mem7[ds:20098:word16] + 18050:byte] = bArg02;
		Mem35[ds:20098:word16] = Mem33[ds:20098:word16] + 0x01;
		dsOut = ds;
		word16 di;
		return di;
	}
}

// 0800:8624: Register byte fn0800-8624(Register Eq_n ds, Stack Eq_n bArg02, Register out uint16 diOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-75EA
//      fn0800-7A02
//      fn0800-7C78
//      fn0800-8489
//      fn0800-854B
//      fn0800-8600
byte fn0800-8624(Eq_n ds, Eq_n bArg02, uint16 & diOut, union Eq_n & dsOut)
{
	Eq_n ax_n = Mem7[ds:0x2A05:word16];
	uint16 di;
	if (SEQ(ax_n, Mem7[ds:0x2A03:word16]) <u Mem7[ds:20100:word32])
	{
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		fn0800-4047(ds, bArg02, Mem7[ds:10719:word32], out cx_n, out dx_n, out bx_n, out di, out ds);
		ax_n = ds:0x2A29[(CONVERT(Mem33[ds:11849:byte] ^ bArg02, uint8, uint16) & 0xFF) * 0x02] ^ Mem33[ds:11849:word16] >>u 0x08;
		Mem58[ds:11849:word16] = ax_n;
		Mem64[ds:0x2A03:ui32] = Mem60[ds:0x2A03:ui32] + 0x01;
	}
	diOut = di;
	dsOut = ds;
	return SLICE(ax_n, byte, 8);
}

// 0800:867A: void fn0800-867A(Stack word16 wArg04, Stack Eq_n psegArg06, Stack Eq_n wArg08, Stack Eq_n psegArg0A)
// Called from:
//      fn0800-09A3
void fn0800-867A(word16 wArg04, Eq_n psegArg06, Eq_n wArg08, Eq_n psegArg0A)
{
	word16 ax_n;
	struct Eq_n Eq_n::* si_n = fn0800-87EF(SEQ(psegArg06, wArg04 + 0x04));
	Eq_n ds_n = psegArg06;
	Eq_n di_n = wArg08;
	Eq_n es_n = psegArg0A;
	byte ah_n = SLICE(ax_n, byte, 8);
	<unknown>* si_n = &si_n->b000A + 1;
	uint8 al_n = ((psegArg06->*si_n).b000A * 0x02 + 0x02) * 0x02;
	bool v48_n;
	do
	{
		uint8 al_n = al_n * 0x02;
		bool v33_n = al_n == 0x00;
		al_n = al_n;
		if (al_n >= 0x00)
		{
			es_n->*di_n.u3 = (char) (ds_n->*si_n);
			si_n = (word16) si_n + 1;
			di_n.u3 = &di_n.u5->b0001;
			al_n = al_n * 0x02;
			v33_n = al_n * 0x02 == 0x00;
			if (al_n * 0x02 < 0x00)
				goto l0800_n;
l0800_n:
			es_n->*di_n.u3 = (char) (ds_n->*si_n);
			si_n = (word16) si_n + 1;
			di_n.u3 = &di_n.u5->b0001;
			continue;
		}
l0800_n:
		if (v33_n)
		{
			si_n = (word16) si_n + 1;
			al_n = ds_n->*si_n *8 0x02 + (byte) (al_n < 0x00);
			if (al_n >= 0x00)
				goto l0800_n;
		}
		uint8 al_n = al_n * 0x02;
		Eq_n bh_n;
		bh_n.u0 = 0x00;
		bool v36_n = al_n >= 0x00;
		if (al_n == 0x00)
		{
			al_n = ds_n->*si_n *8 0x02 + (byte) (al_n < 0x00);
			si_n = (word16) si_n + 1;
			v36_n = al_n >= 0x00;
		}
		Eq_n cx_n;
		cx_n.u0 = 0x02;
		if (v36_n)
		{
			uint8 al_n = al_n * 0x02;
			ui32 C_n = cond(al_n) & 0x02;
			if (al_n == 0x00)
			{
				al_n = ds_n->*si_n *8 0x02 + (byte) (al_n < 0x00);
				si_n = (word16) si_n + 1;
				C_n = cond(al_n) & 0x02;
			}
			al_n = al_n * 0x02;
			Eq_n cl_n = C_n + 0x04;
			bool v39_n = al_n >= 0x00;
			cx_n.u1 = (uint16) cl_n;
			if (al_n == 0x00)
			{
				al_n = ds_n->*si_n *8 0x02 + (byte) (al_n < 0x00);
				si_n = (word16) si_n + 1;
				v39_n = al_n >= 0x00;
			}
			if (!v39_n)
			{
				uint8 al_n = al_n * 0x02;
				al_n = al_n;
				if (al_n == 0x00)
				{
					si_n = (word16) si_n + 1;
					al_n = ds_n->*si_n *8 0x02 + (byte) (al_n < 0x00);
				}
				byte ch_n = SLICE(cx_n - 0x01, byte, 8);
				ui8 cl_n = (cl_n - 0x01) * 0x02 + (byte) (al_n < 0x00);
				cx_n = SEQ(ch_n, cl_n);
				if (cl_n == 0x09)
				{
					word16 cx_n = SEQ(ch_n, 0x04);
					byte ch_n;
					do
					{
						uint8 al_n = al_n * 0x02;
						al_n = al_n;
						if (al_n == 0x00)
						{
							si_n = (word16) si_n + 1;
							al_n = ds_n->*si_n *8 0x02 + (byte) (al_n < 0x00);
						}
						--cx_n;
						bh_n = bh_n *8 0x02 + (byte) (al_n < 0x00);
						ch_n = SLICE(cx_n, byte, 8);
					} while (cx_n != 0x00);
					uint16 cx_n = SEQ(ch_n, ((word32) bh_n + 3) *8 0x02);
					memcpy(&(es_n->*di_n.u3), si_n, cx_n *32 0x02);
					si_n = (<unknown>*) (si_n + cx_n * 0x02);
					di_n.u3 = di_n + cx_n * 0x02;
					continue;
				}
			}
			goto l0800_n;
		}
		al_n = al_n * 0x02;
		bool v42_n = al_n >= 0x00;
		if (al_n == 0x00)
		{
			al_n = ds_n->*si_n *8 0x02 + (byte) (al_n < 0x00);
			si_n = (word16) si_n + 1;
			v42_n = al_n >= 0x00;
		}
		if (v42_n)
			goto l0800_n;
		uint8 al_n = al_n * 0x02;
		bool v45_n = al_n >= 0x00;
		word16 ax_n = SEQ(ah_n, al_n);
		if (al_n == 0x00)
		{
			uint8 al_n = ds_n->*si_n *8 0x02 + (byte) (al_n < 0x00);
			si_n = (word16) si_n + 1;
			v45_n = al_n >= 0x00;
			ax_n = SEQ(ah_n, al_n);
		}
		al_n = (byte) ax_n;
		ah_n = SLICE(ax_n, byte, 8);
		cx_n.u0 = 0x03;
		if (v45_n)
			goto l0800_n;
		uint8 cl_n = (uint8) (ds_n->*si_n);
		si_n = (word16) si_n + 1;
		uint16 cx_n = (uint16) cl_n;
		if (cl_n != 0x00)
		{
			cx_n = cx_n + 0x08;
l0800_n:
			al_n *= 0x02;
			bool v51_n = al_n >= 0x00;
			if (al_n == 0x00)
			{
				al_n = ds_n->*si_n *8 0x02 + (byte) (al_n < 0x00);
				si_n = (word16) si_n + 1;
				v51_n = al_n >= 0x00;
			}
			if (!v51_n)
			{
				uint8 al_n = al_n * 0x02;
				Eq_n C_n = cond(al_n) & 0x02;
				if (al_n == 0x00)
				{
					al_n = ds_n->*si_n *8 0x02 + (byte) (al_n < 0x00);
					si_n = (word16) si_n + 1;
					C_n = cond(al_n) & 0x02;
				}
				al_n = al_n * 0x02;
				bool v54_n = al_n < 0x00;
				if (al_n == 0x00)
				{
					al_n = ds_n->*si_n *8 0x02 + (byte) (al_n < 0x00);
					si_n = (word16) si_n + 1;
					v54_n = al_n < 0x00;
				}
				if (!v54_n)
				{
					bh_n = C_n;
					if (C_n != 0x00)
						goto l0800_n;
					bh_n = (word32) C_n.u1 + 1;
					goto l0800_n;
				}
				uint8 al_n = al_n * 0x02;
				uint8 al_n;
				if (al_n != 0x00)
					al_n = al_n;
				else
				{
					si_n = (word16) si_n + 1;
					al_n = ds_n->*si_n *8 0x02 + (byte) (al_n < 0x00);
				}
				al_n = al_n * 0x02;
				bh_n = C_n *8 0x02 + (byte) (al_n < 0x00) | 0x04;
				bool v57_n = al_n < 0x00;
				if (al_n == 0x00)
				{
					al_n = ds_n->*si_n *8 0x02 + (byte) (al_n < 0x00);
					si_n = (word16) si_n + 1;
					v57_n = al_n < 0x00;
				}
				if (!v57_n)
				{
l0800_n:
					uint8 al_n = al_n * 0x02;
					al_n = al_n;
					if (al_n == 0x00)
					{
						si_n = (word16) si_n + 1;
						al_n = ds_n->*si_n *8 0x02 + (byte) (al_n < 0x00);
					}
					bh_n = bh_n *8 0x02 + (byte) (al_n < 0x00);
				}
			}
l0800_n:
			byte Eq_n::* si_n = di_n - 0x01 - SEQ(bh_n, ds_n->*si_n);
			__cli();
			memcpy(&(es_n->*di_n.u3), &(es_n->*si_n), (uint32) cx_n);
			__sti();
			di_n.u3 = di_n + cx_n;
			si_n = (word16) si_n + 1;
			continue;
		}
		Eq_n ax_n;
		ax_n.u3 = ds_n + (si_n >> 0x04);
		bui8 al_n = (byte) ax_n;
		di_n = (di_n & 0x0F) + 0x8000;
		es_n = es_n + (di_n >> 0x04) - 0x0800;
		si_n &= 0x0F;
		ds_n = ax_n;
		ah_n = SLICE(ax_n, byte, 8);
		al_n = al_n * 0x02;
		v48_n = al_n * 0x02 >= 0x00;
		if (al_n * 0x02 == 0x00)
		{
			al_n = ax_n->*(si_n & 0x0F) *8 0x02 + (byte) (al_n * 0x02 < 0x00);
			si_n = (si_n & 0x0F) + 1;
			v48_n = al_n >= 0x00;
		}
	} while (!v48_n);
}

// 0800:87EF: Register word16 fn0800-87EF(Sequence segptr32 ds_si)
// Called from:
//      fn0800-867A
word16 fn0800-87EF(segptr32 ds_si)
{
	struct Eq_n * ds = SLICE(ds_si, selector, 16);
	word16 si_n = fn0800-87F4(ds_si);
	return fn0800-87F4(si_n);
}

// 0800:87F4: Register word16 fn0800-87F4(Sequence segptr32 ds_si)
// Called from:
//      fn0800-87EF
word16 fn0800-87F4(segptr32 ds_si)
{
	word16 si = (word16) ds_si;
	return si + 2;
}

// 0800:87F8: void fn0800-87F8(Register Eq_n ds)
// Called from:
//      fn0800-75EA
void fn0800-87F8(Eq_n ds)
{
	segptr32 es_di_n = Mem7[ds:11831:segptr32];
	struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
	word16 Eq_n::* di_n = (word16) es_di_n;
	Eq_n ax_n = Mem7[ds:11825:word16];
	word16 cx_n;
	for (cx_n = 0x8000; cx_n != 0x00; --cx_n)
	{
		es_n->*di_n = (word16) ax_n;
		++di_n;
	}
	segptr32 es_di_n = Mem15[ds:0x2E33:segptr32];
	struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
	word16 Eq_n::* di_n = (word16) es_di_n;
	Eq_n ax_n = Mem15[ds:11825:word16];
	word16 cx_n;
	for (cx_n = 0x8000; cx_n != 0x00; --cx_n)
	{
		es_n->*di_n = (word16) ax_n;
		++di_n;
	}
	segptr32 es_di_n = Mem21[ds:11835:segptr32];
	struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
	word16 Eq_n::* di_n = (word16) es_di_n;
	Eq_n cx_n;
	for (cx_n = Mem21[ds:11825:word16]; cx_n != 0x00; --cx_n)
	{
		es_n->*di_n = 0x00;
		++di_n;
	}
	segptr32 es_di_n = Mem30[ds:11839:segptr32];
	struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
	word16 Eq_n::* di_n = (word16) es_di_n;
	word16 ax_n = 0x00;
	Eq_n cx_n = Mem30[ds:11825:word16];
	do
	{
		es_n->*di_n = ax_n;
		++di_n;
		++ax_n;
		--cx_n;
	} while (cx_n != 0x00);
	Mem47[ds:11821:word16] = cx_n;
}

// 0800:8832: void fn0800-8832(Register Eq_n ds)
// Called from:
//      fn0800-7FDC
void fn0800-8832(Eq_n ds)
{
	fn0800-889A(ds);
	if (Mem10[ds:11817:word16] >=u 0x02 && Mem10[ds:11877:word16] - Mem10[ds:11885:word16] >=u 0x03)
	{
		Eq_n ax_n = Mem10[ds:11821:word16];
		Eq_n si_n = Mem10[ds:11817:word16];
		Eq_n di_n = Mem10[ds:11819:word16];
		Eq_n ax_n;
		ax_n.u3 = &ax_n.u5->b0001;
		if (ax_n + 0x01 == Mem32[ds:11825:word16])
			ax_n.u0 = 0x00;
		Mem42[ds:11821:word16] = ax_n;
		Mem44[ds:11885:word16] = Mem42[ds:11885:word16] + 0x01;
		fn0800-889A(ds);
		Mem57[ds:11885:word16] = Mem44[ds:11885:word16] - 0x01;
		Mem60[ds:11821:word16] = ax_n;
		if (Mem60[ds:11817:word16] >u si_n)
		{
			Mem68[ds:11817:word16] = 0x01;
			Mem69[ds:11819:word16] = 0x00;
		}
		else
		{
			Mem65[ds:11817:word16] = si_n;
			Mem67[ds:11819:word16] = di_n;
		}
	}
}

// 0800:889A: void fn0800-889A(Register Eq_n ds)
// Called from:
//      fn0800-8832
void fn0800-889A(Eq_n ds)
{
	Mem13[ds:11819:word16] = 0x00;
	Mem14[ds:11817:word16] = 0x01;
	Eq_n es_di_n = Mem14[ds:11885:segptr32];
	ui16 ax_n = *es_di_n.u1;
	Mem19[ds:20112:word16] = ax_n;
	word16 di_n = (word16) es_di_n;
	word16 dx_n = Mem19[ds:11881:word16] - (di_n + 0x01);
	struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
	byte al_n = (byte) ax_n;
	byte Eq_n::* di_n = di_n + 0x01;
	bool v25_n = dx_n != 0x00;
	word16 cx_n = dx_n;
	while (cx_n != 0x00)
	{
		byte Eq_n::* di_n;
		v25_n = al_n != es_n->*di_n;
		di_n = di_n + 1;
		--cx_n;
		di_n = di_n;
		if (al_n == es_n->*di_n)
			break;
	}
	if (!v25_n)
		--cx_n;
	Mem54[ds:0x4E94:word16] = Mem19[ds:11881:word16] - Mem19[ds:11885:word16];
	uint16 dx_n = dx_n - cx_n;
	uint16 ax_n = Mem54[ds:11833:selector]:0x00[Mem54[ds:20112:word16] * 0x02];
	while (ax_n != Mem62[ds:11825:word16])
	{
		Mem69[ds:20114:word16] = Mem62[ds:11841:selector]:0x00[ax_n * 0x02];
		uint16 bx_n = Mem69[ds:11821:word16];
		if (bx_n <= ax_n)
			bx_n += Mem69[ds:11825:word16];
		ptr32 es_si_n = Mem69[ds:11885:segptr32];
		uint16 bx_n = bx_n - ax_n;
		if (Mem69[ds:20112:word16] == Mem69[SLICE(es_si_n, selector, 16):SLICE(es_si_n, word16, 0) - bx_n:word16])
		{
			uint16 cx_n = Mem69[ds:11837:selector]:0x00[ax_n * 0x02];
			if (cx_n > bx_n)
			{
				bx_n = 0x01;
				cx_n = dx_n;
			}
			else
			{
				if (cx_n > dx_n)
				{
					bx_n -= cx_n - dx_n;
					cx_n = dx_n;
				}
				if (cx_n == dx_n)
				{
					Eq_n es_di_n = Mem69[ds:11885:segptr32];
					<unknown>* di_n = (word16) es_di_n + cx_n;
					struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
					<unknown>* si_n = di_n - bx_n;
					word16 ax_n = Mem69[ds:0x4E94:word16] - cx_n;
					struct Eq_n * ds_n = Mem122[ds:11887:selector];
					Eq_n cmpResult_n = memcmp(si_n, di_n, (uint32) ax_n);
					word16 cx_n = ax_n - __find_first_difference__(si_n, di_n);
					if (cmpResult_n != 0x00)
						++cx_n;
					cx_n = dx_n + (ax_n - cx_n);
				}
			}
			if (cx_n >u Mem150[ds:0x2E2F:word16])
				cx_n = Mem150[ds:0x2E2F:word16];
			if (cx_n >=u Mem150[ds:11817:word16])
			{
				Mem159[ds:11817:word16] = cx_n;
				Mem163[ds:11819:word16] = bx_n;
			}
		}
		ax_n = Mem165[ds:20114:word16];
	}
	if (Mem62[ds:11817:word16] == 0x02 && Mem62[ds:11819:word16] >u 0x0100)
	{
		Mem171[ds:11817:word16] = 0x01;
		Mem172[ds:11819:word16] = 0x00;
	}
}

// 0800:89A8: void fn0800-89A8(Register Eq_n ds, Stack Eq_n wArg02)
// Called from:
//      fn0800-7FDC
void fn0800-89A8(Eq_n ds, Eq_n wArg02)
{
	Eq_n dx_n = Mem11[ds:11825:word16];
l0800_nB1:
	Eq_n di_n = Mem16[ds:11821:word16];
	struct Eq_n * es_n = Mem16[ds:11841:selector];
	Eq_n ax_n;
	ax_n.u2 = es_n->a0000[0].t0000.u3[di_n].t0000.u2;
	es_n->a0000[0].t0000.u3[di_n].t0000.u2 = (uint16) dx_n;
	if (Mem22[ds:11821:word16] != ax_n)
	{
		Eq_n es_di_n = Mem22[ds:11885:segptr32];
		ui16 di_n = SLICE(es_di_n, selector, 16)->*((word16) es_di_n - dx_n);
		Mem22[ds:11833:selector]:0x00[di_n * 0x02] = ax_n;
		if (ax_n == dx_n)
			Mem32[ds:11829:selector]:0x00[di_n * 0x02] = dx_n;
	}
	Eq_n di_n = Mem38[Mem38[ds:11885:segptr32] + 0x00:word16];
	Eq_n ax_n = Mem38[ds:11821:word16];
	struct Eq_n * es_n = Mem38[ds:11833:selector];
	if (es_n->a0000[0].t0000.u3[di_n].t0000.u2 == dx_n)
		es_n->a0000[0].t0000.u3[di_n].t0000.u2 = (uint16) ax_n;
	else
		Mem38[ds:11841:selector]:0x00[Mem38[ds:11829:selector]:0x00[di_n * 0x02] * 0x02] = ax_n;
	Mem57[ds:11829:selector]:0x00[di_n * 0x02] = ax_n;
	Eq_n es_di_n = Mem61[ds:11885:segptr32];
	word16 di_n = (word16) es_di_n;
	word16 bx_n = Mem61[ds:11881:word16] - (di_n + 0x01);
	struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
	Eq_n al_n = *es_di_n.u3;
	union Eq_n Eq_n::* di_n = di_n + 0x01;
	bool v27_n = bx_n != 0x00;
	word16 cx_n = bx_n;
	while (cx_n != 0x00)
	{
		union Eq_n Eq_n::* di_n;
		v27_n = al_n != (es_n->*di_n).u1;
		di_n = (union Eq_n Eq_n::*) ((char *) di_n + 1);
		--cx_n;
		di_n = di_n;
		if (al_n == (es_n->*di_n).u1)
			break;
	}
	if (!v27_n)
		--cx_n;
	cup16 bx_n = bx_n - cx_n;
	Mem61[ds:11837:selector]:0x00[Mem61[ds:11821:word16] * 0x02] = bx_n;
	while (true)
	{
		Eq_n ax_n = Mem102[ds:11821:word16];
		Eq_n ax_n;
		ax_n.u3 = &ax_n.u5->b0001;
		if (&ax_n.u5->b0001 == dx_n)
			ax_n.u0 = 0x00;
		Mem114[ds:11821:word16] = ax_n;
		Mem116[ds:11885:word16] = Mem114[ds:11885:word16] + 0x01;
		Eq_n v23_n = wArg02 - 0x01;
		wArg02 = v23_n;
		if (v23_n == 0x00)
			break;
		--bx_n;
		if (bx_n <= 0x01)
			goto l0800_nB1;
		Eq_n di_n = Mem122[ds:11821:word16];
		Mem122[ds:11837:selector]:0x00[di_n *16 0x02] = bx_n;
		struct Eq_n * es_n = Mem139[ds:11841:selector];
		Eq_n v25_n;
		v25_n.u2 = es_n->a0000[0].t0000.u3[di_n].t0000.u2;
		es_n:0x00[di_n *16 0x02] = Mem139[ds:11821:word16];
		if (Mem143[ds:11821:word16] != v25_n)
		{
			Eq_n es_di_n = Mem143[ds:11885:segptr32];
			ui16 di_n = SLICE(es_di_n, selector, 16)->*((word16) es_di_n - dx_n);
			Mem143[ds:11833:selector]:0x00[di_n * 0x02] = v25_n;
			if (v25_n == dx_n)
				Mem155[ds:11829:selector]:0x00[di_n * 0x02] = dx_n;
		}
	}
}

// 0800:8ACF: void fn0800-8ACF(Register Eq_n ds, Stack (ptr32 char) ptrArg02, Stack (ptr32 word16) ptrArg06)
void fn0800-8ACF(Eq_n ds, char * ptrArg02, word16 * ptrArg06)
{
	word16 cx_n;
	Eq_n ax_n;
	if (!msdos_get_file_attributes(ptrArg02, out cx_n, out ax_n))
		*ptrArg06 = cx_n;
	else
		fn0800-8D64(ds, ax_n);
}

// 0800:8B0D: Register byte fn0800-8B0D(Register Eq_n ds, Stack Eq_n wArg02, Stack word16 wArg04, Stack word16 wArg06, Register out word16 dxOut)
// Called from:
//      fn0800-8B5A
//      fn0800-8B69
byte fn0800-8B0D(Eq_n ds, Eq_n wArg02, word16 wArg04, word16 wArg06, word16 & dxOut)
{
	mp16 fp;
	if (wArg06 == 0x00)
	{
		while (Mem19[ds:0x224E:word16] != 0x00)
		{
			Mem23[ds:0x224E:word16] = Mem19[ds:0x224E:word16] - 0x01;
			ui16 bx_n = Mem23[ds:0x224E:word16];
			selector seg0800;
			(seg0800->*(*((word32) ds + 20118))[bx_n])();
		}
		fn0800-0150();
		0x0800:Mem19[ds:0x2352:word16]();
	}
	word16 dx_n;
	fn0800-01B9(ds, out dx_n);
	fn0800-0163();
	mp16 sp_n = fp - 4;
	if (wArg04 != 0x00)
	{
		dxOut = dx_n;
		return 0x00;
	}
	else
	{
		if (wArg06 == 0x00)
		{
			0x0800:Mem58[ds:9044:word16]();
			0x0800:Mem58[ds:0x2356:word16]();
		}
		union Eq_n Eq_n::* sp_n = sp_n - 2;
		selector ss;
		(ss->*sp_n).u1 = (word16) wArg02;
		fn0800-0164((ss->*sp_n).u0);
	}
}

// 0800:8B5A: Register byte fn0800-8B5A(Register Eq_n ds, Stack Eq_n wArg02, Register out word16 dxOut)
// Called from:
//      fn0800-0D24
//      fn0800-0DCE
byte fn0800-8B5A(Eq_n ds, Eq_n wArg02, word16 & dxOut)
{
	word16 dx_n;
	fn0800-8B0D(ds, wArg02, 0x00, 0x00, out dx_n);
	dxOut = dx_n;
	return 0x00;
}

// 0800:8B69: void fn0800-8B69(Register Eq_n ds, Stack Eq_n wArg02)
void fn0800-8B69(Eq_n ds, Eq_n wArg02)
{
	word16 dx_n;
	fn0800-8B0D(ds, wArg02, 0x00, 0x01, out dx_n);
}

// 0800:8B95: void fn0800-8B95(Stack (ptr32 Eq_n) ptrArg02)
// Called from:
//      fn0800-9764
void fn0800-8B95(struct Eq_n * ptrArg02)
{
	word16 cx_n;
	byte dh_n;
	byte dl_n = msdos_get_system_date(out dh_n, out cx_n);
	ptrArg02->w0000 = cx_n;
	ptrArg02->w0002 = SEQ(dh_n, dl_n);
}

// 0800:8BA8: void fn0800-8BA8(Stack (ptr32 Eq_n) ptrArg02)
// Called from:
//      fn0800-9764
void fn0800-8BA8(struct Eq_n * ptrArg02)
{
	byte dl_n;
	byte dh_n;
	byte ch_n;
	byte cl_n = msdos_get_system_time(out ch_n, out dh_n, out dl_n);
	ptrArg02->w0000 = SEQ(ch_n, cl_n);
	ptrArg02->w0002 = SEQ(dh_n, dl_n);
}

// 0800:8BBB: Sequence int32 fn0800-8BBB(Stack Eq_n dwArg00, Stack Eq_n dwArg04, Register out word16 cxOut)
// Called from:
//      main
//      fn0800_B6D6
//      fn0800_C177
int32 fn0800-8BBB(Eq_n dwArg00, Eq_n dwArg04, word16 & cxOut)
{
	int16 dx_n;
	word16 cx_n;
	uint16 ax_n = fn0800-8BBE(dwArg00, dwArg04, out cx_n, out dx_n);
	cxOut = cx_n;
	return SEQ(dx_n, ax_n);
}

// 0800:8BBE: Register word16 fn0800-8BBE(Stack Eq_n dwArg04, Stack Eq_n dwArg08, Register out word16 cxOut, Register out word16 dxOut)
// Called from:
//      fn0800-8BBB
word16 fn0800-8BBE(Eq_n dwArg04, Eq_n dwArg08, word16 & cxOut, word16 & dxOut)
{
	word16 bx_n;
	word16 dx_n;
	word16 cx_n;
	word16 ax_n = fn0800-8BD8(0x00, dwArg04, dwArg08, out cx_n, out dx_n, out bx_n);
	cxOut = cx_n;
	dxOut = dx_n;
	return ax_n;
}

// 0800:8BC2: Sequence word32 fn0800-8BC2(Stack Eq_n dwArg00, Stack Eq_n dwArg04, Register out word16 cxOut, Register out word16 bxOut)
// Called from:
//      fn0800-0B79
//      fn0800-4550
//      fn0800-7FDC
word32 fn0800-8BC2(Eq_n dwArg00, Eq_n dwArg04, word16 & cxOut, word16 & bxOut)
{
	word16 bx_n;
	word16 dx_n;
	word16 cx_n;
	word16 ax_n = fn0800-8BC5(dwArg00, dwArg04, out cx_n, out dx_n, out bx_n);
	cxOut = cx_n;
	bxOut = bx_n;
	return SEQ(dx_n, ax_n);
}

// 0800:8BC5: Register word16 fn0800-8BC5(Stack Eq_n dwArg04, Stack Eq_n dwArg08, Register out word16 cxOut, Register out word16 dxOut, Register out word16 bxOut)
// Called from:
//      fn0800-8BC2
word16 fn0800-8BC5(Eq_n dwArg04, Eq_n dwArg08, word16 & cxOut, word16 & dxOut, word16 & bxOut)
{
	word16 bx_n;
	word16 dx_n;
	word16 cx_n;
	word16 ax_n = fn0800-8BD8(0x01, dwArg04, dwArg08, out cx_n, out dx_n, out bx_n);
	cxOut = cx_n;
	dxOut = dx_n;
	bxOut = bx_n;
	return ax_n;
}

// 0800:8BCA: Sequence int32 fn0800-8BCA(Stack Eq_n dwArg00, Stack Eq_n dwArg04)
// Called from:
//      main
//      fn0800_C177
int32 fn0800-8BCA(Eq_n dwArg00, Eq_n dwArg04)
{
	int16 dx_n;
	return SEQ(dx_n, fn0800-8BCD(dwArg00, dwArg04, out dx_n));
}

// 0800:8BCD: Register word16 fn0800-8BCD(Stack Eq_n dwArg04, Stack Eq_n dwArg08, Register out word16 dxOut)
// Called from:
//      fn0800-8BCA
word16 fn0800-8BCD(Eq_n dwArg04, Eq_n dwArg08, word16 & dxOut)
{
	word16 bx_n;
	word16 dx_n;
	word16 cx_n;
	word16 ax_n = fn0800-8BD8(0x02, dwArg04, dwArg08, out cx_n, out dx_n, out bx_n);
	dxOut = dx_n;
	return ax_n;
}

// 0800:8BD8: Register uint16 fn0800-8BD8(Register uint16 cx, Stack Eq_n dwArg04, Stack Eq_n dwArg08, Register out ci16 cxOut, Register out word16 dxOut, Register out uint16 bxOut)
// Called from:
//      fn0800-8BBE
//      fn0800-8BC5
//      fn0800-8BCD
uint16 fn0800-8BD8(uint16 cx, Eq_n dwArg04, Eq_n dwArg08, ci16 & cxOut, word16 & dxOut, uint16 & bxOut)
{
	ci16 wArg06 = SLICE(dwArg04, word16, 16);
	uint16 wArg08 = (word16) dwArg08;
	ci16 wArg0A = SLICE(dwArg08, word16, 16);
	uint16 di_n = cx;
	ci16 cx_n = wArg0A;
	uint16 bx_n;
	uint16 ax_n;
	word16 dx_n;
	if (wArg0A == 0x00 && (wArg06 == 0x00 || wArg08 == 0x00))
	{
		bx_n = wArg08;
		uint16 dx_n = dwArg04 % wArg08;
		ax_n = dwArg04 /u wArg08;
		if ((cx & 0x02) != 0x00)
			ax_n = dx_n;
		dx_n = 0x00;
	}
	else
	{
		Eq_n cx_bx_n = dwArg08;
		Eq_n dx_ax_n = dwArg04;
		if ((cx & 0x01) == 0x00)
		{
			Eq_n dx_ax_n = dwArg04;
			if (wArg06 < 0x00)
			{
				dx_ax_n = -dwArg04;
				di_n = cx | 0x0C;
			}
			cx_bx_n = dwArg08;
			dx_ax_n = dx_ax_n;
			if (wArg0A < 0x00)
			{
				cx_bx_n = -dwArg08;
				di_n = di_n ^ 0x04;
				dx_ax_n = dx_ax_n;
			}
		}
		uint16 bx_n = (word16) cx_bx_n;
		uint16 cx_n = SLICE(cx_bx_n, word16, 16);
		uint16 di_n = 0x00;
		uint16 si_n = 0x00;
		Eq_n dx_ax_n = dx_ax_n;
		word16 ax_n;
		word16 dx_n;
		for (cx_n = 0x20; cx_n != 0x00; --cx_n)
		{
			ui32 v33_n = dx_ax_n << 0x01;
			si_n = __rcl<word16,byte>(si_n, 0x01, (SLICE(dx_ax_n, word16, 16) & 0x8000) != 0x00);
			ax_n = (word16) v33_n;
			dx_n = SLICE(v33_n, word16, 16);
			di_n = __rcl<word16,byte>(di_n, 0x01, (si_n & 0x8000) != 0x00);
			if (di_n >= cx_n && (di_n > cx_n || si_n >= bx_n))
			{
				ui32 di_si_n = SEQ(di_n, si_n) - cx_bx_n;
				si_n = (word16) di_si_n;
				di_n = SLICE(di_si_n, word16, 16);
				++ax_n;
			}
			dx_ax_n = SEQ(dx_n, ax_n);
		}
		bx_n = di_n;
		uint32 dx_ax_n = SEQ(dx_n, ax_n);
		if ((di_n & 0x02) != 0x00)
		{
			bx_n = di_n >> 0x01;
			dx_ax_n = SEQ(di_n, si_n);
		}
		ax_n = (word16) dx_ax_n;
		dx_n = SLICE(dx_ax_n, word16, 16);
		if ((bx_n & 0x04) != 0x00)
		{
			uint32 dx_ax_n = -dx_ax_n;
			ax_n = (word16) dx_ax_n;
			dx_n = SLICE(dx_ax_n, word16, 16);
		}
	}
	cxOut = cx_n;
	dxOut = dx_n;
	bxOut = bx_n;
	return ax_n;
}

// 0800:8C69: Sequence Eq_n fn0800-8C69(Sequence Eq_n dx_ax, Register Eq_n cl)
// Called from:
//      fn0800-46FE
//      fn0800-4C55
//      fn0800-4F2C
//      fn0800-55E8
//      fn0800-5C39
//      fn0800-5E64
//      fn0800-6F20
//      fn0800_A215
Eq_n fn0800-8C69(Eq_n dx_ax, Eq_n cl)
{
	ui16 dx_n;
	return SEQ(dx_n, fn0800-8C6C(dx_ax, cl, out dx_n));
}

// 0800:8C6C: Register cui16 fn0800-8C6C(Sequence Eq_n dx_ax, Register Eq_n cl, Register out ui16 dxOut)
// Called from:
//      fn0800-8C69
cui16 fn0800-8C6C(Eq_n dx_ax, Eq_n cl, ui16 & dxOut)
{
	cui16 ax = (word16) dx_ax;
	if (cl >= 0x10)
	{
		dxOut = ax << cl - 0x10;
		return 0x00;
	}
	else
	{
		ui32 dx_ax_n = dx_ax << cl;
		dxOut = SLICE(dx_ax_n, word16, 16);
		return (word16) dx_ax_n;
	}
}

// 0800:8C8A: Register word16 fn0800-8C8A(Sequence Eq_n dx_ax, Register cu8 cl, Register out byte clOut, Register out word16 dxOut)
// Called from:
//      fn0800-12E2
//      fn0800-1F5C
//      fn0800-24FE
//      fn0800-2688
//      fn0800-46FE
word16 fn0800-8C8A(Eq_n dx_ax, cu8 cl, byte & clOut, word16 & dxOut)
{
	word16 dx_n;
	byte cl_n;
	word16 ax_n = fn0800-8C8D(dx_ax, cl, out cl_n, out dx_n);
	clOut = cl_n;
	dxOut = dx_n;
	return ax_n;
}

// 0800:8C8D: Register int16 fn0800-8C8D(Sequence Eq_n dx_ax, Register cu8 cl, Register out cu8 clOut, Register out word16 dxOut)
// Called from:
//      fn0800-8C8A
int16 fn0800-8C8D(Eq_n dx_ax, cu8 cl, cu8 & clOut, word16 & dxOut)
{
	ci16 dx = SLICE(dx_ax, word16, 16);
	if (cl >= 0x10)
	{
		clOut = cl - 0x10;
		dxOut = 0x00;
		return dx >> cl - 0x10;
	}
	else
	{
		clOut = -cl + 0x10;
		Eq_n dx_ax_n = dx_ax >> cl;
		dxOut = SLICE(dx_ax_n, word16, 16);
		return (word16) dx_ax_n;
	}
}

// 0800:8CAA: Sequence Eq_n fn0800-8CAA(Sequence Eq_n dx_ax, Register cu8 cl)
// Called from:
//      fn0800-0DE8
//      fn0800-112D
//      fn0800-12E2
//      fn0800-3992
//      fn0800-46FE
//      fn0800-4F2C
//      fn0800-51A9
//      fn0800-5E64
//      fn0800-6F20
Eq_n fn0800-8CAA(Eq_n dx_ax, cu8 cl)
{
	ui16 dx_n;
	return SEQ(dx_n, fn0800-8CAD(dx_ax, cl, out dx_n));
}

// 0800:8CAD: Register uint16 fn0800-8CAD(Sequence Eq_n dx_ax, Register cu8 cl, Register out word16 dxOut)
// Called from:
//      fn0800-8CAA
uint16 fn0800-8CAD(Eq_n dx_ax, cu8 cl, word16 & dxOut)
{
	cu16 dx = SLICE(dx_ax, word16, 16);
	if (cl >= 0x10)
	{
		dxOut = 0x00;
		return dx >> cl - 0x10;
	}
	else
	{
		uint32 dx_ax_n = dx_ax >> cl;
		dxOut = SLICE(dx_ax_n, word16, 16);
		return (word16) dx_ax_n;
	}
}

// 0800:8CCB: Register Eq_n fn0800-8CCB(Sequence uint32 cx_bx, Register Eq_n ax, Register Eq_n dx, Register out byte chOut, Register out word16 dxOut)
// Called from:
//      fn0800_A215
//      fn0800_ABA3
//      fn0800_AD85
Eq_n fn0800-8CCB(uint32 cx_bx, Eq_n ax, Eq_n dx, byte & chOut, word16 & dxOut)
{
	word16 dx_n;
	byte ch_n;
	Eq_n ax_n = fn0800-8CCE(cx_bx, ax, dx, out ch_n, out dx_n);
	chOut = <invalid>;
	dxOut = dx_n;
	return ax_n;
}

// 0800:8CCE: Register Eq_n fn0800-8CCE(Sequence uint32 cx_bx, Register Eq_n ax, Register Eq_n dx, Register out byte chOut, Register out word16 dxOut)
// Called from:
//      fn0800-8CCB
Eq_n fn0800-8CCE(uint32 cx_bx, Eq_n ax, Eq_n dx, byte & chOut, word16 & dxOut)
{
	ci16 cx = SLICE(cx_bx, word16, 16);
	word16 bx = (word16) cx_bx;
	byte dh_n = SLICE(dx, byte, 8);
	byte dl_n = (byte) dx;
	byte cl_n = (byte) cx;
	if (cx >= 0x00)
	{
		cu16 ax_n = (word16) ax + bx;
		byte al_n = (byte) ax_n;
		if (ax_n < 0x00)
		{
			dh_n = SLICE((word32) dx + 0x00001000, byte, 8);
			dl_n = (byte) dx;
		}
		chOut = <invalid>;
		dxOut = SEQ(dh_n + (cl_n << 0x04), dl_n) + (ax_n >> 0x04);
		return SEQ(SLICE(ax_n >> 0x04, byte, 8), al_n) & 0x0F;
	}
	else
	{
		ui32 cx_bx_n = ~cx_bx;
		word16 bx_n = (word16) cx_bx_n + 0x01;
		byte cl_n = SLICE(cx_bx_n + 0x01, byte, 16);
		cu16 ax_n = ax - bx_n;
		byte al_n = (byte) ax_n;
		if (ax_n < 0x00)
			dx -= 0x1000;
		chOut = <invalid>;
		dxOut = dx - SEQ(cl_n << 0x04, 0x00) + (ax_n >> 0x04);
		return SEQ(SLICE(ax_n >> 0x04, byte, 8), al_n) & 0x0F;
	}
}

// 0800:8D2B: Register word16 fn0800-8D2B(Register Eq_n ds, Stack Eq_n wArg02)
// Called from:
//      fn0800-8D64
//      fn0800-8E29
//      fn0800-8E52
//      fn0800-8F50
//      fn0800-8F7F
//      fn0800-97F8
//      fn0800_A2A3
//      fn0800_A401
//      fn0800_A53C
//      fn0800_A559
//      fn0800_A57F
//      fn0800_A59D
//      fn0800_A817
//      fn0800_A84A
//      fn0800_B113
//      fn0800_B140
//      fn0800_B2A0
//      fn0800_B97F
//      fn0800_BA4A
//      fn0800_C632
//      fn0800_C779
word16 fn0800-8D2B(Eq_n ds, Eq_n wArg02)
{
	Eq_n si_n = wArg02;
	int16 si_n;
	if (wArg02 >= 0x00)
	{
		if (wArg02 <= 88)
			goto l0800_nD3E;
	}
	else
	{
		si_n = -wArg02;
		if (si_n <= 0x23)
		{
			Mem23[ds:9494:word16] = ~0x00;
l0800_nD58:
			Mem36[ds:0x7F:word16] = si_n;
			return ~0x00;
		}
	}
	si_n.u0 = 0x57;
l0800_nD3E:
	Mem30[ds:9494:word16] = si_n;
	si_n = (int16) (ds->*((word32) si_n + 9496));
	goto l0800_nD58;
}

// 0800:8D64: void fn0800-8D64(Register Eq_n ds, Stack Eq_n wArg02)
// Called from:
//      fn0800-8ACF
void fn0800-8D64(Eq_n ds, Eq_n wArg02)
{
	fn0800-8D2B(ds, wArg02);
}

// 0800:8D76: Register cui16 fn0800-8D76(Stack int16 wArg02)
// Called from:
//      fn0800_A96D
cui16 fn0800-8D76(int16 wArg02)
{
	cui16 dx_n;
	msdos_ioctl_get_device_info(wArg02, out dx_n);
	return dx_n & 0x80;
}

// 0800:8D87: void fn0800-8D87(Stack Eq_n bArg02, Stack Eq_n bArg04, Stack Eq_n wArg06, Stack Eq_n ptrArg08, Stack Eq_n dwArg0C)
// Called from:
//      fn0800-8E09
//      fn0800-9828
void fn0800-8D87(Eq_n bArg02, Eq_n bArg04, Eq_n wArg06, Eq_n ptrArg08, Eq_n dwArg0C)
{
	Eq_n fp;
	uint16 wArg0C = (word16) dwArg0C;
	Eq_n wArg0E = SLICE(dwArg0C, word16, 16);
	struct Eq_n * es_n = SLICE(ptrArg08, selector, 16);
	byte Eq_n::* di_n = (word16) ptrArg08;
	cu8 bl_n = (byte) wArg06;
	if (wArg06 > 0x24 || bl_n < 0x02)
	{
l0800_nDF7:
		es_n->*di_n = 0x00;
		return;
	}
	uint16 ax_n = wArg0C;
	Eq_n cx_n = wArg0E;
	if (wArg0E < 0x00 && bArg04 != 0x00)
	{
		*ptrArg08.u3 = 0x2D;
		ui32 cx_ax_n = -dwArg0C;
		++di_n;
		ax_n = (word16) cx_ax_n;
		cx_n = SLICE(cx_ax_n, word16, 16);
	}
	byte Eq_n::* si_n = fp - 36;
	selector ss;
	if (cx_n != 0x00)
	{
		Eq_n ax_n;
		do
		{
			uint32 dx_ax_n = (uint32) cx_n;
			uint32 dx_ax_n = SEQ(dx_ax_n % wArg06, ax_n);
			ss->*si_n = (byte) (dx_ax_n % wArg06);
			ax_n = dx_ax_n /u wArg06;
			cx_n = ax_n;
			ax_n = dx_ax_n /u wArg06;
			++si_n;
		} while (ax_n != 0x00);
l0800_nDD9:
		if (ax_n == 0x00)
		{
			int16 cx_n = (int16) (si_n + (36 - fp));
			do
			{
				--si_n;
				cu8 al_n = ss->*si_n;
				byte al_n;
				if (al_n < 0x0A)
					al_n = al_n + 0x30;
				else
					al_n = (byte) (bArg02.u3 + (al_n - 0x0A));
				es_n->*di_n = al_n;
				++di_n;
				--cx_n;
			} while (cx_n != 0x00);
			goto l0800_nDF7;
		}
	}
	uint32 dx_ax_n = (uint32) ax_n;
	ss->*si_n = (byte) (dx_ax_n % wArg06);
	ax_n = dx_ax_n /u wArg06;
	++si_n;
	goto l0800_nDD9;
}

// 0800:8E09: void fn0800-8E09(Stack Eq_n dwArg02, Stack uint16 wArg06)
// Called from:
//      fn0800-8E6A
void fn0800-8E09(Eq_n dwArg02, uint16 wArg06)
{
	fn0800-8D87(0x61, 0x00, 0x0A, dwArg02, (uint32) wArg06);
}

// 0800:8E29: Register Eq_n fn0800-8E29(Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n dwArg04, Stack byte bArg08, Register out word16 cxOut, Register out word16 dxOut)
// Called from:
//      fn0800-97B6
//      fn0800_ACB3
//      fn0800_B324
//      fn0800_B4BE
//      fn0800_B97F
//      fn0800_C632
Eq_n fn0800-8E29(Eq_n ds, Eq_n wArg02, Eq_n dwArg04, byte bArg08, word16 & cxOut, word16 & dxOut)
{
	int32 * dx_ax_n;
	word16 wArg06 = SLICE(dwArg04, word16, 16);
	(*((word32) ds + 9450))[wArg02] &= ~0x0200;
	Eq_n ax_n = (word16) dx_ax_n;
	word16 dx_n = SLICE(dx_ax_n, word16, 16);
	if (msdos_set_file_position(wArg02, dwArg04, bArg08, out dx_ax_n))
	{
		int32 * dx_ax_n = (int32 *) fn0800-8D2B(ds, ax_n);
		ax_n = (word16) dx_ax_n;
		dx_n = SLICE(dx_ax_n, word16, 16);
	}
	cxOut = wArg06;
	dxOut = dx_n;
	return ax_n;
}

// 0800:8E52: Register Eq_n fn0800-8E52(Register Eq_n ds, Stack Eq_n ptrArg02)
// Called from:
//      fn0800-3678
Eq_n fn0800-8E52(Eq_n ds, Eq_n ptrArg02)
{
	Eq_n ax_n;
	Eq_n ax_n;
	if (!msdos_mkdir(ptrArg02, out ax_n))
		ax_n.u0 = 0x00;
	else
		ax_n = fn0800-8D2B(ds, ax_n);
	return ax_n;
}

// 0800:8E6A: Sequence Eq_n fn0800-8E6A(Register Eq_n ds, Stack uint16 wArg02, Stack cui16 wArg04, Stack cui16 wArg06, Stack Eq_n dwArg08)
// Called from:
//      fn0800_A614
Eq_n fn0800-8E6A(Eq_n ds, uint16 wArg02, cui16 wArg04, cui16 wArg06, Eq_n dwArg08)
{
	Eq_n dwArg08_n = dwArg08;
	if (dwArg08 == 0x00)
		dwArg08_n = SEQ(ds, 20182);
	Eq_n dx_ax_n;
	if ((wArg04 | wArg06) == 0x00)
		dx_ax_n = SEQ(ds, 0x2572);
	else
		dx_ax_n = SEQ(wArg06, wArg04);
	fn0800-8E09(fn0800-9CE6(dwArg08_n, dx_ax_n), wArg02);
	fn0800_BF5F(dwArg08_n, SEQ(ds, 9590));
	return dwArg08_n;
}

// 0800:8F18: Sequence word32 fn0800-8F18(Register Eq_n ax, Register uint16 cx, Register uint16 dx, Register Eq_n bx, Register out byte chOut)
// Called from:
//      fn0800-0B79
//      fn0800-7FDC
//      fn0800_ABA3
//      fn0800_AD85
//      fn0800_C04F
//      fn0800_C379
word32 fn0800-8F18(Eq_n ax, uint16 cx, uint16 dx, Eq_n bx, byte & chOut)
{
	uint16 ax_n = dx;
	if (dx != 0x00)
		ax_n = bx *16 dx;
	if (cx != 0x00)
		ax_n = ax *16 cx + ax_n;
	chOut = <invalid>;
	uint32 dx_ax_n = bx * ax;
	return SEQ(SLICE(dx_ax_n, word16, 16) + ax_n, (word16) dx_ax_n);
}

// 0800:8F2F: FlagGroup ui32 fn0800-8F2F(Register Eq_n ax, Register (ptr16 Eq_n) cx, Register Eq_n dx, Register Eq_n bx, Register out word16 cxOut, Register out word16 dxOut, Register out cui16 bxOut)
// Called from:
//      fn0800_A1D6
//      fn0800_A215
//      fn0800_B0A1
ui32 fn0800-8F2F(Eq_n ax, struct Eq_n * cx, Eq_n dx, Eq_n bx, word16 & cxOut, word16 & dxOut, cui16 & bxOut)
{
	byte al = (byte) ax;
	byte bl = (byte) bx;
	word16 dx_n = (word16) (dx.u3 + (ax >> 0x04));
	word16 cx_n = cx + (bx >> 0x04);
	Eq_n SCZO_n;
	SCZO_n.u1 = cond(dx_n - cx_n);
	cui16 ax_n = SEQ(bl, al);
	cui16 bx_n = SEQ(SLICE(bx >> 0x04, byte, 8), bl);
	ui32 Z_n = SCZO_n & 0x04;
	ui32 C_n = SCZO_n & 0x02;
	if (dx_n == cx_n)
	{
		Eq_n SCZO_n;
		SCZO_n.u1 = cond((ax_n & 0x0F) - (bx_n & 0x0F));
		C_n = SCZO_n & 0x02;
		Z_n = SCZO_n & 0x04;
	}
	cxOut = cx_n;
	dxOut = dx_n;
	bxOut = bx_n & 0x0F;
	return C_n | Z_n;
}

// 0800:8F50: Register Eq_n fn0800-8F50(Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n ptrArg04, Stack Eq_n wArg08, Register out byte chOut)
// Called from:
//      fn0800_AAB3
//      fn0800_B97F
Eq_n fn0800-8F50(Eq_n ds, Eq_n wArg02, Eq_n ptrArg04, Eq_n wArg08, byte & chOut)
{
	Eq_n wLoc04_n;
	Eq_n ax_n;
	if (((*((word32) ds + 9450))[wArg02] & 0x02) != 0x00)
		wLoc04_n.u0 = 0x05;
	else
	{
		if (!msdos_read_file(wArg02, wArg08, ptrArg04, out ax_n))
			goto l0800_nF7D;
		wLoc04_n = ax_n;
	}
	ax_n = fn0800-8D2B(ds, wLoc04_n);
l0800_nF7D:
	chOut = <invalid>;
	return ax_n;
}

// 0800:8F7F: Register word16 fn0800-8F7F(Register Eq_n ds, Stack Eq_n ptrArg02)
// Called from:
//      fn0800-0DA9
//      fn0800-0DE8
//      fn0800-112D
//      fn0800-12E2
//      fn0800-19EE
//      fn0800-37DF
//      fn0800-388C
//      fn0800-3BC3
//      fn0800-3C99
word16 fn0800-8F7F(Eq_n ds, Eq_n ptrArg02)
{
	word16 dx_n = (word16) ptrArg02;
	Eq_n ax_n;
	if (msdos_delete_file(ptrArg02, out ax_n))
		fn0800-8D2B(ds, ax_n);
	return dx_n;
}

// 0800:8F97: Register Eq_n fn0800-8F97(Register Eq_n di, Register Eq_n ds, Stack (memptr (ptr16 Eq_n) code) wArg02, Stack (memptr (ptr16 Eq_n) code) wArg04, Stack mp16 wArg06, Stack selector wArg08, Stack (memptr Eq_n Eq_n) wArg0A, Stack Eq_n psegArg0C)
// Called from:
//      fn0800_BF18
Eq_n fn0800-8F97(Eq_n di, Eq_n ds, <anonymous> seg0800_t::* wArg02, <anonymous> seg0800_t::* wArg04, mp16 wArg06, selector wArg08, struct Eq_n Eq_n::* wArg0A, Eq_n psegArg0C)
{
	struct Eq_n Eq_n::* sp_n;
	Eq_n ax_n;
	<unknown> ϕ;
	struct Eq_n Eq_n::* sp_n;
	<unknown> ϕ;
	Eq_n wLoc08_n;
	<unknown> ϕ;
	ci16 ax_n;
	<unknown> ϕ;
	<unknown> ϕ;
	word16 di_n;
	<unknown> ϕ;
	<unknown> ϕ;
	<unknown> ϕ;
	Eq_n di_n;
	word16 dx_n;
	<unknown> ϕ;
	<unknown> ϕ;
	<unknown> ϕ;
	<unknown> ϕ;
	<unknown> ϕ;
	<unknown> ϕ;
	<unknown> ϕ;
	ci16 si_n;
	<unknown> ϕ;
	struct Eq_n * es_di_n;
	struct Eq_n * es_di_n;
	<unknown> ϕ;
	struct Eq_n Eq_n::* si_n;
	<unknown> ϕ;
	Eq_n dl_n;
	<unknown> ϕ;
	Eq_n di_n;
	<unknown> ϕ;
	ui8 ch_n;
	<unknown> ϕ;
	Eq_n al_n;
	<unknown> ϕ;
	struct Eq_n Eq_n::* si_n;
	<unknown> ϕ;
	<unknown> ϕ;
	<unknown> ϕ;
	<unknown> ϕ;
	word16 cx_n;
	<unknown> ϕ;
	word16 Eq_n::* di_n;
	<unknown> ϕ;
	word16 di_n;
	ci16 ax_n;
	<unknown> ϕ;
	<unknown> ϕ;
	<unknown> ϕ;
	<unknown> ϕ;
	<unknown> ϕ;
	<unknown> ϕ;
	<unknown> ϕ;
	Eq_n di_n;
	<unknown> ϕ;
	int8 bLoc03_n;
	int8 bLoc03_n;
	int8 bLoc03_n;
	int8 bLoc03_n;
	int8 bLoc03_n;
	int8 bLoc03_n;
	<unknown> ϕ;
	Eq_n wLoc0C_n;
	Eq_n wLoc0C_n;
	<unknown> ϕ;
	struct Eq_n Eq_n::* si_n;
	<unknown> ϕ;
	Eq_n di_n;
	<unknown> ϕ;
	struct Eq_n Eq_n::* wArg0A_n;
	<unknown> ϕ;
	Eq_n di_n;
	Eq_n di_n;
	Eq_n di_n;
	Eq_n di_n;
	Eq_n di_n;
	<unknown> ϕ;
	struct Eq_n Eq_n::* wArg0A_n;
	struct Eq_n Eq_n::* wArg0A_n;
	<unknown> ϕ;
	Eq_n wLoc08_n;
	Eq_n wLoc08_n;
	Eq_n wLoc08_n;
	<unknown> ϕ;
	byte Eq_n::* fp;
	struct Eq_n * ss;
	Eq_n di;
	Eq_n ds;
	struct Eq_n Eq_n::* wArg0A;
	Eq_n psegArg0C;
	ci16 wLoc0A;
	selector wArg08;
	mp16 wArg06;
	<anonymous> seg0800_t::* wArg02;
	<anonymous> seg0800_t::* wArg04;
	Eq_n wLoc08_n;
	wLoc08_n.u1 = 0x00;
l0800_nFC8:
	Eq_n wLoc08_n = ϕ(wLoc08_n, wLoc08_n, wLoc08_n, wLoc08_n, wLoc08_n, wLoc08_n);
	struct Eq_n Eq_n::* wArg0A_n = ϕ(wArg0A, wArg0A_n, wArg0A_n, wArg0A_n, wArg0A_n, wArg0A_n);
	Eq_n di_n = ϕ(di, di_n, di_n, di_n, di_n, di_n);
	<unknown> ϕ;
	Mem49 = ϕ(Mem45, Mem1062, Mem1063, Mem1064, Mem591, Mem529);
	struct Eq_n Eq_n::* si_n = wArg0A_n;
	byte Eq_n::* fp;
	selector seg0800;
	struct Eq_n * ss;
	Eq_n ax_n;
	struct Eq_n Eq_n::* sp_n;
	Eq_n ax_n;
	do
	{
l0800_nFCB:
		struct Eq_n Eq_n::* wArg0A_n = ϕ(wArg0A_n, wArg0A_n, wArg0A_n);
		<unknown> ϕ;
		Eq_n wLoc08_n;
		Eq_n wLoc08_n;
		wLoc08_n = ϕ(wLoc08_n, wLoc08_n, wLoc08_n);
		Eq_n di_n = ϕ(di_n, di_n, di_n);
		struct Eq_n Eq_n::* si_n = ϕ(si_n, si_n, si_n);
		<unknown> ϕ;
		Mem53 = ϕ(Mem1014, Mem888, Mem49);
		Eq_n al_n;
		al_n.u0 = (psegArg0C->*si_n).t0000.u0;
		struct Eq_n Eq_n::* si_n = (struct Eq_n Eq_n::*) &si_n->t0001.u0;
		Eq_n al_n = al_n;
		if (al_n == 0x00)
		{
			Eq_n di_n;
			fn0800-93A6(fp - 2, out di_n);
			return di_n;
		}
		struct Eq_n Eq_n::* si_n;
		Eq_n di_n;
		Eq_n al_n;
		if (al_n == 0x25)
		{
			Eq_n wLoc0C_n;
			wLoc0C_n.u0 = ~0x00;
			Eq_n es_n = psegArg0C;
			int8 bLoc03_n = 0x20;
			while (true)
			{
				Eq_n wLoc0C_n = ϕ(wLoc0C_n, wLoc0C_n, wLoc0C_n, wLoc0C_n, wLoc0C_n, wLoc0C_n, wLoc0C_n, wLoc0C_n, wLoc0C_n, wLoc0C_n);
				int8 bLoc03_n = ϕ(bLoc03_n, bLoc03_n, bLoc03_n, bLoc03_n, bLoc03_n, bLoc03_n, bLoc03_n, bLoc03_n, bLoc03_n, bLoc03_n);
				Eq_n di_n = ϕ(di_n, di_n, di_n, di_n, di_n, di_n, di_n, di_n, di_n, di_n);
				<unknown> ϕ;
				Mem80 = ϕ(Mem77, Mem840, Mem497, Mem117, Mem122, Mem86, Mem492, Mem487, Mem825, Mem837);
				struct Eq_n Eq_n::* si_n = ϕ(si_n, si_n, si_n, si_n, si_n, si_n, si_n, si_n, si_n, si_n);
				Eq_n al_n;
				al_n.u0 = (psegArg0C->*si_n).t0000.u0;
				si_n = (struct Eq_n Eq_n::*) &si_n->t0001.u0;
				Eq_n ax_n;
				ax_n.u0 = (int16) al_n;
				wArg0A_n = si_n;
				di_n = ax_n;
				if (ax_n < 0x00)
					break;
				uint16 bx_n = (uint16) (ds->*((word16) ax_n + 9596));
				if (bx_n > 0x15)
				{
					Eq_n di_n;
					fn0800-93A6(fp - 2, out di_n);
					return di_n;
				}
				switch (bx_n)
				{
				case 0x00:
				case 0x01:
				case 0x02:
					Eq_n di_n;
					fn0800-93A6(fp - 2, out di_n);
					return di_n;
				case 0x03:
					di_n = di_n;
					al_n = al_n;
					goto l0800_nFD8;
				case 0x04:
					bLoc03_n = bLoc03_n | 0x01;
					break;
				case 0x05:
					wLoc0C_n = ax_n - 0x30;
					di_n = wLoc0C_n;
					if (wLoc0C_n >= 0x00)
						wLoc0C_n = ax_n - 0x30 + wLoc0C_n * 0x0A;
					break;
				case 0x06:
					Eq_n di_n;
					Eq_n es_n;
					if ((bLoc03_n & 0x01) == 0x00)
					{
						struct Eq_n * es_di_n = fn0800-8FAB(fp - 2, ds);
						di_n = (word16) es_di_n;
						es_n.u3 = SLICE(es_di_n, selector, 16);
					}
					Eq_n di_n = ϕ(di_n, di_n);
					Eq_n es_n = ϕ(es_n, es_n);
					Eq_n si_n = wLoc0C_n;
					Eq_n si_n;
					if (wLoc0C_n < 0x00)
						si_n.u0 = 0x01;
					Eq_n si_n = ϕ(si_n, si_n);
					Eq_n wLoc08_n;
					Eq_n di_n;
					if (wLoc0C_n != 0x00)
					{
						Eq_n si_n;
						do
						{
							Eq_n wLoc08_n = ϕ(wLoc08_n, wLoc08_n);
							Eq_n di_n = ϕ(di_n, di_n);
							Eq_n si_n = ϕ(si_n, si_n);
							Eq_n v69_n;
							v69_n.u1 = (word16) wLoc08_n.u1 + 1;
							(seg0800->*wArg02)();
							wLoc08_n = v69_n;
							byte al_n = (byte) ax_n;
							if (ax_n < 0x00)
							{
								Eq_n di_n;
								fn0800-93A6(&(ss->*(fp - 2)), out di_n);
								return di_n;
							}
							Eq_n di_n;
							if ((bLoc03_n & 0x01) == 0x00)
							{
								es_n->*di_n = al_n;
								di_n = (word16) di_n + 1;
							}
							<unknown> ϕ;
							di_n = ϕ(di_n, di_n);
							<unknown> ϕ;
							Mem815 = ϕ(Mem764, Mem802);
							si_n = si_n - 0x01;
						} while (si_n > 0x00);
					}
					<unknown> ϕ;
					wLoc08_n = ϕ(wLoc08_n, wLoc08_n);
					<unknown> ϕ;
					di_n = ϕ(di_n, di_n);
					<unknown> ϕ;
					Mem813 = ϕ(Mem86, Mem815);
					<unknown> ϕ;
					Mem1063 = ϕ(Mem813, Mem821);
					goto l0800_nFC8;
				case 0x07:
				case 0x08:
					uint16 si_n = 0x0A;
					goto l0800_nCE;
				case 0x09:
					uint16 si_n = 0x00;
					goto l0800_nCE;
				case 0x0A:
					fn0800_A2D0(ds);
					ci16 wLoc0A;
					if (wLoc0A > 0x00)
					{
						if (((int16) bLoc03_n & 0x01) == 0x00)
						{
							di_n = (word16) fn0800-8FAB(&(ss->*(fp - 2)), ds);
							fn0800_A2D4(ds);
						}
						else
							fn0800_A2D8(ds);
						goto l0800_nFC8;
					}
					fn0800_A2D8(ds);
					if (wLoc0A < 0x00)
					{
						Eq_n di_n;
						fn0800-93A6(&(ss->*(fp - 2)), out di_n);
						return di_n;
					}
					else
					{
						Eq_n di_n;
						fn0800-93BE(&(ss->*(fp - 2)), out di_n);
						return di_n;
					}
				case 11:
					bLoc03_n = bLoc03_n | 0x08;
					break;
				case 0x0C:
					bLoc03_n = bLoc03_n | 0x02;
					break;
				case 0x0D:
					bLoc03_n = bLoc03_n | 0x04;
					break;
				case 0x0E:
					uint16 si_n = 0x08;
					goto l0800_nCE;
				case 0x0F:
					word16 bp_n = fn0800-920E(fp - 2, ds, out di_n);
					Eq_n di_n;
					fn0800-920E(bp_n, ds, out di_n);
					return di_n;
				case 0x10:
					word16 Eq_n::* di_n = fp - 44;
					word16 cx_n = 0x10;
					while (true)
					{
						word16 Eq_n::* di_n = ϕ(di_n, di_n);
						<unknown> ϕ;
						Mem172 = ϕ(Mem164, Mem458);
						word16 cx_n = ϕ(cx_n, cx_n);
						if (cx_n == 0x00)
							break;
						ss->*di_n = 0x00;
						di_n = di_n + 1;
						cx_n = cx_n - 0x01;
					}
					byte v53_n = bLoc03_n & ~0x10;
					Eq_n al_n;
					al_n.u0 = (psegArg0C->*si_n).t0000.u0;
					struct Eq_n Eq_n::* si_n = (struct Eq_n Eq_n::*) &si_n->t0001.u0;
					byte bLoc03_n = v53_n;
					byte bLoc03_n;
					Eq_n al_n;
					struct Eq_n Eq_n::* si_n;
					if (al_n == 0x5E)
					{
						bLoc03_n = v53_n | 0x10;
						al_n.u0 = (psegArg0C->*si_n).t0001.u0;
						si_n = (struct Eq_n Eq_n::*) ((char *) &si_n->t0001 + 1);
					}
					byte bLoc03_n = ϕ(bLoc03_n, bLoc03_n);
					struct Eq_n Eq_n::* si_n = ϕ(si_n, si_n);
					<unknown> ϕ;
					Mem1070 = ϕ(Mem180, Mem185);
					Eq_n al_n = ϕ(al_n, al_n);
l0800_nD2:
					struct Eq_n Eq_n::* si_n = ϕ(si_n, si_n, si_n, si_n);
					<unknown> ϕ;
					Mem206 = ϕ(Mem1070, Mem214, Mem214, Mem214);
					Eq_n al_n = ϕ(al_n, al_n, al_n, al_n);
					uint16 ax_n = (uint16) al_n;
					ui8 ch_n = 0x01 << (al_n & 0x07);
					ss->*((fp - 44) + (ax_n >> 0x03)) = (word16) (ss->*((fp - 44) + (ax_n >> 0x03)) | ch_n);
					Eq_n dl_n = al_n;
					Eq_n di_n = ax_n >> 0x03;
					while (true)
					{
						ui8 ch_n = ϕ(ch_n, ch_n, ch_n);
						Eq_n di_n = ϕ(di_n, di_n, di_n);
						Eq_n dl_n = ϕ(dl_n, dl_n, dl_n);
						<unknown> ϕ;
						Mem214 = ϕ(Mem208, Mem214, Mem448);
						struct Eq_n Eq_n::* si_n = ϕ(si_n, si_n, si_n);
						al_n.u0 = (psegArg0C->*si_n).t0000.u0;
						si_n = (struct Eq_n Eq_n::*) &si_n->t0001.u0;
						if (al_n == 0x00)
							break;
						if (al_n == 0x5D)
						{
							ci16 v68_n = wLoc0C_n & 0x7FFF;
							wArg0A_n = si_n;
							ci16 si_n = v68_n;
							struct Eq_n * es_di_n = SEQ(psegArg0C, di_n);
							struct Eq_n * es_di_n;
							if ((bLoc03_n & 0x01) == 0x00)
								es_di_n = fn0800-8FAB(&(ss->*(fp - 2)), ds);
							Eq_n wLoc08_n;
							Eq_n di_n;
							struct Eq_n * es_n;
							struct Eq_n * es_n;
							while (true)
							{
								struct Eq_n * es_di_n = ϕ(es_di_n, es_di_n, es_di_n, es_di_n);
								<unknown> ϕ;
								Eq_n wLoc08_n;
								wLoc08_n = ϕ(wLoc08_n, wLoc08_n, wLoc08_n, wLoc08_n);
								<unknown> ϕ;
								Mem254 = ϕ(Mem232, Mem232, Mem267, Mem373);
								ci16 si_n = ϕ(si_n, si_n, si_n, si_n);
								di_n = (word16) es_di_n;
								es_n = SLICE(es_di_n, selector, 16);
								ci16 si_n = si_n - 0x01;
								if (si_n < 0x00)
									break;
								Eq_n v72_n;
								v72_n.u1 = (word16) wLoc08_n.u1 + 1;
								(seg0800->*wArg02)();
								wLoc08_n = v72_n;
								wchar_t ax_n;
								if (ax_n < 0x00)
								{
									if (si_n + 0x01 >= v68_n)
									{
										Eq_n di_n;
										fn0800-93A6(&(ss->*(fp - 2)), out di_n);
										return di_n;
									}
									if ((bLoc03_n & 0x01) != 0x00)
									{
										Eq_n di_n;
										fn0800-93A6(&(ss->*(fp - 2)), out di_n);
										return di_n;
									}
									else
									{
										es_di_n->t0000.u0 = 0x00;
										Eq_n di_n;
										fn0800-93A6(&(ss->*(fp - 2)), out di_n);
										return di_n;
									}
								}
								si_n = si_n;
								Eq_n al_n = (byte) ax_n;
								if ((ss->*((fp - 44) + (ax_n >> 0x03)) & 0x01 << ((byte) ax_n & 0x07)) != 0x00)
								{
									if ((bLoc03_n & 0x10) != 0x00)
										goto l0800_nD;
								}
								else if ((bLoc03_n & 0x10) == 0x00)
								{
l0800_nD:
									(seg0800->*wArg04)();
									struct Eq_n Eq_n::* sp_n;
									es_n = (ss->*sp_n).ptr0006;
									if (si_n + 0x01 < v68_n)
										break;
									goto l0800_nE;
								}
								es_di_n = es_di_n;
								if ((bLoc03_n & 0x01) == 0x00)
								{
									es_di_n->t0000.u0 = (byte) al_n;
									es_di_n = (struct Eq_n *) ((word16) di_n + 1);
								}
							}
							struct Eq_n * es_n = ϕ(es_n, es_n);
							<unknown> ϕ;
							Mem410 = ϕ(Mem254, Mem404);
							Eq_n di_n;
							if ((bLoc03_n & 0x01) == 0x00)
							{
l0800_nE:
								struct Eq_n * es_n = ϕ(es_n, es_n);
								es_n->*di_n = 0x00;
								di_n = (word16) di_n + 1;
							}
							<unknown> ϕ;
							di_n = ϕ(di_n, di_n);
							<unknown> ϕ;
							Mem1064 = ϕ(Mem410, Mem423);
							wLoc08_n = wLoc08_n;
							goto l0800_nFC8;
						}
						if (al_n != 0x2D || (dl_n > ((psegArg0C->*si_n).t0000).u0 || ((psegArg0C->*si_n).t0000).u0 == 0x5D))
							goto l0800_nD2;
						si_n = (struct Eq_n Eq_n::*) &si_n->t0001.u0;
						cu8 al_n = (psegArg0C->*si_n).t0000.u0 - dl_n;
						if (al_n != 0x00)
						{
							dl_n = (byte) dl_n + al_n;
							cu8 al_n;
							do
							{
								cu8 al_n = ϕ(al_n, al_n);
								<unknown> ϕ;
								Mem446 = ϕ(Mem214, Mem448);
								Eq_n di_n = ϕ(di_n, di_n);
								ui8 ch_n = ϕ(ch_n, ch_n);
								ch_n = __rol<byte,byte>(ch_n, 0x01);
								di_n = (word16) di_n + (word16) ((ch_n & 0x80) != 0x00);
								ss->*((fp - 44) + di_n) = (word16) (ss->*((fp - 44) + di_n) | ch_n);
								al_n = al_n - 0x01;
							} while (al_n != 0x00);
						}
					}
					Eq_n di_n;
					fn0800-93BE(&(ss->*(fp - 2)), out di_n);
					return di_n;
				case 0x11:
					Eq_n ax_n = wLoc08_n;
					word16 dx_n = 0x00;
					if ((bLoc03_n & 0x01) == 0x00)
						goto l0800_n;
					break;
				case 0x12:
					uint16 si_n = 0x10;
l0800_nCE:
					uint16 si_n = ϕ(si_n, si_n, si_n, si_n);
					int8 bLoc03_n;
					if ((ax_n & 0x20) == 0x00 && ax_n != 88)
						bLoc03_n = bLoc03_n | 0x04;
					int8 bLoc03_n = ϕ(bLoc03_n, bLoc03_n, bLoc03_n);
					Eq_n ax_n = fn0800-94B0(ds, wArg02, wArg04, wArg06, wArg08, si_n, wLoc0C_n & 0x7FFF, fp - 8, fp - 0x0A, out dx_n, out di_n);
					if (wLoc0A > 0x00)
					{
						Eq_n di_n;
						Eq_n di_n;
						if ((bLoc03_n & 0x01) == 0x00)
						{
l0800_n:
							int8 bLoc03_n = ϕ(bLoc03_n, bLoc03_n);
							word16 dx_n = ϕ(dx_n, dx_n);
							Eq_n ax_n = ϕ(ax_n, ax_n);
							struct Eq_n * es_di_n = fn0800-8FAB(fp - 2, ds);
							es_di_n->t0000.u1 = (word16) ax_n;
							word16 di_n = (word16) es_di_n;
							di_n = di_n + 2;
							if ((bLoc03_n & 0x04) != 0x00)
							{
								es_di_n->w0002 = dx_n;
								di_n = di_n + 4;
							}
						}
						<unknown> ϕ;
						di_n = ϕ(di_n, di_n, di_n);
						<unknown> ϕ;
						Mem1062 = ϕ(Mem712, Mem722, Mem656);
						goto l0800_nFC8;
					}
					if (wLoc0A < 0x00)
					{
						Eq_n di_n;
						fn0800-93A6(&(ss->*(fp - 2)), out di_n);
						return di_n;
					}
					else
					{
						Eq_n di_n;
						fn0800-93BE(&(ss->*(fp - 2)), out di_n);
						return di_n;
					}
				case 0x13:
					word16 bp_n = fn0800-912A(fp - 2, ds, out di_n);
					Eq_n di_n;
					fn0800-912A(bp_n, ds, out di_n);
					return di_n;
				case 0x14:
					bLoc03_n = bLoc03_n & 223;
					break;
				case 0x15:
					bLoc03_n = bLoc03_n | 0x20;
					break;
				}
			}
			Eq_n di_n;
			fn0800-93A6(fp - 2, out di_n);
			return di_n;
		}
l0800_nFD8:
		<unknown> ϕ;
		wArg0A_n = ϕ(wArg0A_n, wArg0A_n);
		<unknown> ϕ;
		si_n = ϕ(si_n, si_n);
		Eq_n di_n = ϕ(di_n, di_n);
		Eq_n al_n = ϕ(al_n, al_n);
		(seg0800->*wArg02)();
		ax_n.u0 = (int16) al_n;
		wLoc08_n.u1 = (word16) wLoc08_n.u1 + 1;
		selector cx_n = (ss->*sp_n).pseg0002;
		struct Eq_n Eq_n::* sp_n = (struct Eq_n Eq_n::*) (&sp_n->pseg0002 + 1);
		int8 al_n = (byte) ax_n;
		if (ax_n < 0x00)
		{
l0800_n:
			Eq_n di_n;
			fn0800-93A6(fp - 2, out di_n);
			return di_n;
		}
		ax_n.u0 = (int16) al_n;
		di_n = ax_n;
		if (ax_n >= 0x00 && ds->*((word16) ax_n + 9596) == 0x01)
		{
			Eq_n ax_n;
			do
			{
				Eq_n wLoc08_n = ϕ(wLoc08_n, wLoc08_n);
				struct Eq_n Eq_n::* sp_n = ϕ(sp_n, sp_n);
				<unknown> ϕ;
				Mem977 = ϕ(Mem888, Mem1024);
				Eq_n ax_n = ϕ(ax_n, ax_n);
				if ((byte) ax_n < 0x00 || ds->*((word16) ax_n + 9596) != 0x01)
				{
					struct Eq_n Eq_n::* sp_n = sp_n - 2;
					(ss->*sp_n).pseg0000 = wArg08;
					(ss->*sp_n).wFFFFFFFE = wArg06;
					(ss->*sp_n).tFFFFFFFC.u0 = (int16) ax_n;
					(seg0800->*wArg04)();
					wLoc08_n = wLoc08_n - 0x01;
					goto l0800_nFCB;
				}
				struct Eq_n Eq_n::* sp_n = sp_n - 2;
				(ss->*sp_n).pseg0000 = wArg08;
				(ss->*sp_n).wFFFFFFFE = wArg06;
				(seg0800->*wArg02)();
				wLoc08_n.u1 = (word16) wLoc08_n.u1 + 1;
				selector cx_n = (ss->*sp_n).pseg0002;
				sp_n = (struct Eq_n Eq_n::*) (&sp_n->pseg0002 + 1);
				ax_n = ax_n;
			} while (ax_n > 0x00);
			goto l0800_n;
		}
	} while (ax_n == ax_n);
	(ss->*sp_n).pseg0002 = wArg08;
	(ss->*sp_n).w0000 = wArg06;
	(ss->*sp_n).tFFFFFFFE.u0 = (int16) ax_n;
	(seg0800->*wArg04)();
	Eq_n di_n;
	fn0800-93A6(fp - 2, out di_n);
	return di_n;
}

// 0800:8FAB: Sequence segptr32 fn0800-8FAB(Sequence (ptr32 Eq_n) ss_bp, Register Eq_n ds)
// Called from:
//      fn0800-8F97
segptr32 fn0800-8FAB(struct Eq_n * ss_bp, Eq_n ds)
{
	<unknown>* es_di_n = ss_bp->ptr0010;
	segptr32 Eq_n::* di_n = (word16) es_di_n;
	if ((ss_bp->bFFFFFFFF & 0x20) == 0x00)
	{
		<unknown> Eq_n::* di_n = (<unknown> Eq_n::*) *es_di_n;
		ss_bp->ptr0010 = ss_bp->ptr0010;
		return SEQ(ds, di_n);
	}
	else
	{
		segptr32 es_di_n = ds->*di_n;
		ss_bp->ptr0010 = ss_bp->ptr0010;
		return es_di_n;
	}
}

// 0800:912A: Register word16 fn0800-912A(Sequence (ptr32 Eq_n) ss_bp, Register Eq_n ds, Register out word16 diOut)
// Called from:
//      fn0800-8F97
word16 fn0800-912A(struct Eq_n * ss_bp, Eq_n ds, word16 & diOut)
{
	word16 di_n;
	word16 bp_n = fn0800-93C5(ss_bp, ds, out di_n);
	diOut = di_n;
	return bp_n;
}

// 0800:9145: void fn0800-9145(Sequence (ptr32 Eq_n) ss_bp)
void fn0800-9145(struct Eq_n * ss_bp)
{
	fn0800-93EF(ss_bp);
}

// 0800:9169: void fn0800-9169(Sequence (ptr32 Eq_n) ss_bp)
void fn0800-9169(struct Eq_n * ss_bp)
{
	fn0800-93EF(ss_bp);
}

// 0800:920E: Register word16 fn0800-920E(Sequence (ptr32 Eq_n) ss_bp, Register Eq_n ds, Register out word16 diOut)
// Called from:
//      fn0800-8F97
word16 fn0800-920E(struct Eq_n * ss_bp, Eq_n ds, word16 & diOut)
{
	word16 di_n;
	word16 bp_n = fn0800-93C5(ss_bp, ds, out di_n);
	diOut = di_n;
	return bp_n;
}

// 0800:93A6: Register word16 fn0800-93A6(Sequence (ptr32 Eq_n) ss_bp, Register out word16 diOut)
// Called from:
//      fn0800-8F97
//      fn0800-912A
//      fn0800-93EF
word16 fn0800-93A6(struct Eq_n * ss_bp, word16 & diOut)
{
	word16 di_n;
	selector seg0800;
	(seg0800->*ss_bp->ptr0006)();
	ss_bp->wFFFFFFFC -= (word16) (ss_bp->wFFFFFFFC < 0x01);
	word16 bp_n = fn0800-93BE(ss_bp, out di_n);
	diOut = di_n;
	return bp_n;
}

// 0800:93BE: Register word16 fn0800-93BE(Sequence (ptr32 Eq_n) ss_bp, Register out word16 diOut)
// Called from:
//      fn0800-8F97
//      fn0800-93A6
word16 fn0800-93BE(struct Eq_n * ss_bp, word16 & diOut)
{
	word16 bp_n = ss_bp->w0000;
	word16 wArg02;
	diOut = wArg02;
	return bp_n;
}

// 0800:93C5: Register word16 fn0800-93C5(Sequence (ptr32 Eq_n) ss_bp, Register Eq_n ds, Register out word16 diOut)
// Called from:
//      fn0800-912A
//      fn0800-920E
word16 fn0800-93C5(struct Eq_n * ss_bp, Eq_n ds, word16 & diOut)
{
	word16 di_n;
	mp16 fp;
	struct Eq_n * ss = SLICE(ss_bp, selector, 16);
	word16 bp = (word16) ss_bp;
	mp16 sp_n = fp;
	ci8 al_n;
	Eq_n ax_n;
	do
	{
		++ss_bp->wFFFFFFFA;
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		(ss->*sp_n).w0000 = ss_bp->w000A;
		(ss->*sp_n).wFFFFFFFE = ss_bp->w0008;
		selector seg0800;
		(seg0800->*ss_bp->ptr0004)();
		sp_n = fp - 2;
		al_n = (byte) ax_n;
		if (ax_n <= 0x00)
		{
			if (ax_n == 0x00)
				break;
			word16 bp_n = fn0800-93A6(ss_bp, out di_n);
			diOut = di_n;
			return bp_n;
		}
	} while (al_n >= 0x00 && ds->*((word16) ax_n + 9596) == 0x01);
	Eq_n wLoc02;
	(*((word32) wLoc02 + 3))();
	word16 di;
	diOut = di;
	return bp;
}

// 0800:93EF: void fn0800-93EF(Sequence (ptr32 Eq_n) ss_bp)
// Called from:
//      fn0800-9145
//      fn0800-9169
void fn0800-93EF(struct Eq_n * ss_bp)
{
	ci16 ax_n;
	struct Eq_n Eq_n::* fp;
	struct Eq_n * ss = SLICE(ss_bp, selector, 16);
	struct Eq_n Eq_n::* sp_n = fp;
	word16 dx_n = 0x00;
	word16 cx_n = 0x04;
	ci8 cl_n;
	while (true)
	{
		ci16 v9_n = ss_bp->wFFFFFFF6 - 0x01;
		ss_bp->wFFFFFFF6 = v9_n;
		cl_n = (byte) cx_n;
		if (v9_n < 0x00)
			break;
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		(ss->*sp_n).w0000 = dx_n;
		(ss->*sp_n).wFFFFFFFE = cx_n;
		++ss_bp->wFFFFFFFA;
		(ss->*sp_n).wFFFFFFFC = ss_bp->w000A;
		(ss->*sp_n).wFFFFFFFA = ss_bp->w0008;
		selector seg0800;
		(seg0800->*ss_bp->ptr0004)();
		struct Eq_n Eq_n::* sp_n;
		cl_n = (ss->*sp_n).b0004;
		cui16 dx_n = (ss->*sp_n).w0006;
		sp_n = (struct Eq_n Eq_n::*) (&sp_n->w0006 + 1);
		cu8 al_n = (byte) ax_n;
		if (ax_n <= 0x00)
			break;
		--cl_n;
		if (cl_n < 0x01)
			break;
		cu8 ch_n = al_n - 0x30;
		if (al_n < 0x30)
			break;
		if (al_n >= 0x3A)
		{
			cu8 ch_n = al_n - 0x41;
			if (al_n < 0x41)
				break;
			if (al_n >= 0x47)
			{
				ch_n = al_n - 0x61;
				if (al_n < 0x61 || al_n >= 0x67)
					break;
			}
			ch_n = ch_n + 0x0A;
		}
		dx_n = SEQ(SLICE(dx_n << 0x04, byte, 8), ((byte) dx_n << 0x04) + ch_n);
		cx_n = SEQ(ch_n, cl_n - 0x01);
	}
	if (cl_n == 0x04)
	{
		word16 di_n;
		fn0800-93A6(ss_bp, out di_n);
	}
	else
	{
		Eq_n wLoc02;
		(*((word32) wLoc02 + 3))();
	}
}

// 0800:9485: FlagGroup bool fn0800-9485(Register uint8 cl, Register byte bl, Register out uint16 bxOut)
// Called from:
//      fn0800-94B0
bool fn0800-9485(uint8 cl, byte bl, uint16 & bxOut)
{
	uint16 bx;
	cu8 bl_n = (byte) bx;
	uint8 bl_n = bl_n - 0x30;
	word32 C_n;
	uint16 bx_n;
	if (bl_n >= 0x30)
	{
		if (bl_n <= 0x39)
		{
l0800_nA2:
			if (bl_n < cl)
			{
				C_n = 0x00;
				bx_n = (uint16) bl_n;
l0800_nAF:
				bxOut = bx_n;
				return C_n != 0x00;
			}
			goto l0800_nAD;
		}
		if (bl_n <= 0x5A && bl_n >= 0x30)
			bl_n = bl_n - 55;
		else
			bl_n = bl_n - 0x57;
		if (bl_n > 0x09)
			goto l0800_nA2;
	}
l0800_nAD:
	bx_n = bx;
	C_n = 0x02;
	goto l0800_nAF;
}

// 0800:94B0: Register uint16 fn0800-94B0(Register Eq_n ds, Stack (memptr (ptr16 Eq_n) code) wArg02, Stack (memptr (ptr16 Eq_n) code) wArg04, Stack mp16 wArg06, Stack selector wArg08, Stack uint16 wArg0A, Stack ci16 wArg0C, Stack (ptr32 word16) ptrArg0E, Stack (ptr32 word16) ptrArg12, Register out Eq_n dxOut, Register out selector diOut)
// Called from:
//      fn0800-8F97
uint16 fn0800-94B0(Eq_n ds, <anonymous> seg0800_t::* wArg02, <anonymous> seg0800_t::* wArg04, mp16 wArg06, selector wArg08, uint16 wArg0A, ci16 wArg0C, word16 * ptrArg0E, word16 * ptrArg12, union Eq_n & dxOut, selector & diOut)
{
	uint16 bx_n;
	mp16 fp;
	selector Eq_n::* sp_n = fp - 0x0C;
	uint8 bLoc03_n = 0x00;
	word16 wLoc06_n = 0x00;
	word16 v9_n;
	selector ss;
	selector seg0800;
	struct Eq_n Eq_n::* sp_n;
	Eq_n ax_n;
	Eq_n al_n;
	Eq_n ax_n;
	do
	{
		v9_n = wLoc06_n + 0x01;
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		(ss->*sp_n).pseg0000 = wArg08;
		(ss->*sp_n).wFFFFFFFE = wArg06;
		(seg0800->*wArg02)();
		wLoc06_n = v9_n;
		sp_n = (selector Eq_n::*) (&sp_n->pseg0002 + 1);
		Eq_n ax_n;
		ax_n = ax_n;
		al_n = (byte) ax_n;
		if (ax_n < 0x00)
			goto l0800_n;
		ax_n.u0 = (int16) al_n;
	} while ((al_n & 0x80) == 0x00 && (ds->*((word16) ax_n + 8785) & 0x01) != 0x00);
	ax_n = ax_n;
	ci16 wArg0C_n = wArg0C - 0x01;
	word16 wLoc08_n;
	uint16 ax_n;
	Eq_n dx_n;
	if (wArg0C < 0x01)
	{
l0800_n:
		wLoc08_n = 0x00;
l0800_n:
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		(ss->*sp_n).pseg0000 = wArg08;
		(ss->*sp_n).wFFFFFFFE = wArg06;
		(ss->*sp_n).tFFFFFFFC.u0 = (int16) ax_n;
		(seg0800->*wArg04)();
		word16 sp_n;
		sp_n = sp_n + 0x06;
		--wLoc06_n;
		ax_n = 0x00;
		dx_n.u1 = 0x00;
		goto l0800_n;
	}
	Eq_n ax_n;
	if (al_n != 0x2B)
	{
		ax_n.u1 = (uint16) al_n;
		if (al_n != 0x2D)
			goto l0800_nF;
		bLoc03_n = 0x01;
	}
	wArg0C_n = wArg0C - 0x02;
	if (wArg0C < 0x02)
		goto l0800_n;
	(ss->*sp_n).pseg0002 = wArg08;
	(ss->*sp_n).w0000 = wArg06;
	(seg0800->*wArg02)();
	wLoc06_n = v9_n + 0x01;
	word16 sp_n;
	sp_n = sp_n + 4;
	ax_n = ax_n;
	if (ax_n < 0x00)
	{
l0800_n:
		wLoc08_n = ~0x00;
		goto l0800_n;
	}
l0800_nF:
	byte al_n = (byte) ax_n;
	cu8 cl_n = (byte) wArg0A;
	word16 ax_n;
	uint32 di_si_n;
	uint32 di_si_n;
	if (wArg0A == 0x00)
	{
		wArg0A = 0x0A;
		if (al_n == 0x30)
		{
			ci16 v74_n = wArg0C_n - 0x01;
			wArg0C_n = v74_n;
			if (v74_n >= 0x00)
			{
				struct Eq_n Eq_n::* sp_n = sp_n - 2;
				(ss->*sp_n).pseg0000 = wArg08;
				(ss->*sp_n).wFFFFFFFE = wArg06;
				(seg0800->*wArg02)();
				++wLoc06_n;
				byte al_n = (byte) ax_n;
				word16 sp_n;
				sp_n = sp_n + 4;
				wArg0A = 0x08;
				if (al_n != 0x78)
				{
					di_si_n = 0x00;
					if (al_n != 88)
					{
l0800_nC8:
						ui16 di_n = SLICE(di_si_n, word16, 16);
						uint16 si_n = (word16) di_si_n;
						uint16 ax_n = bx_n;
						uint32 di_si_n;
						if (!fn0800-9485((byte) wArg0A, (byte) ax_n, out bx_n))
						{
							di_si_n = di_si_n;
l0800_n:
							struct Eq_n Eq_n::* sp_n = sp_n - 2;
							(ss->*sp_n).pseg0000 = wArg08;
							(ss->*sp_n).wFFFFFFFE = wArg06;
							(ss->*sp_n).wFFFFFFFC = ax_n;
							(seg0800->*wArg04)();
							word16 sp_n;
							sp_n = sp_n + 0x06;
							--wLoc06_n;
							di_si_n = di_si_n;
l0800_n:
							wLoc08_n = 0x01;
							dx_n.u1 = SLICE(di_si_n, word16, 16);
							ax_n = (word16) di_si_n;
							if (bLoc03_n != 0x00)
							{
								Eq_n dx_ax_n = -di_si_n;
								ax_n = (word16) dx_ax_n;
								dx_n.u1 = SLICE(dx_ax_n, word16, 16);
							}
							goto l0800_n;
						}
						di_si_n = SEQ(di_n, bx_n) + wArg0A *32 si_n;
						if (SLICE(di_si_n, word16, 16) != 0x00)
						{
							Eq_n dx_ax_n;
							uint32 ax_si_n;
							do
							{
								ci16 v58_n = wArg0C_n - 0x01;
								uint16 di_n = SLICE(di_si_n, word16, 16);
								uint16 si_n = (word16) di_si_n;
								wArg0C_n = v58_n;
								di_si_n = di_si_n;
								if (v58_n < 0x00)
									goto l0800_n;
								struct Eq_n Eq_n::* sp_n = sp_n - 2;
								(ss->*sp_n).pseg0000 = wArg08;
								(ss->*sp_n).wFFFFFFFE = wArg06;
								(seg0800->*wArg02)();
								++wLoc06_n;
								word16 sp_n;
								sp_n = sp_n + 4;
								uint16 bx_n;
								ax_n = bx_n;
								di_si_n = di_si_n;
								word16 ax_n;
								if (!fn0800-9485((byte) wArg0A, (byte) ax_n, out bx_n))
									goto l0800_n;
								dx_ax_n = wArg0A *32 di_n;
								ax_si_n = SEQ((word16) dx_ax_n, bx_n) + wArg0A *32 si_n;
								di_si_n = ax_si_n;
							} while (SLICE(dx_ax_n, byte, 16) + SLICE(dx_ax_n, byte, 24) + (byte) (SLICE(ax_si_n, word16, 16) < 0x00) == 0x00);
							uint16 ah_al_n = (uint16) bLoc03_n + ~0x00;
							dx_n = (cond(SLICE(ah_al_n, byte, 8)) & 0x02) + 0x7FFF;
							wLoc08_n = 0x02;
							ax_n = ah_al_n;
l0800_n:
							*ptrArg0E += wLoc06_n;
							*ptrArg12 = wLoc08_n;
							selector di_n = ss->*sp_n;
							dxOut = dx_n;
							diOut = di_n;
							return ax_n;
						}
l0800_nB5:
						ci16 v48_n = wArg0C_n - 0x01;
						wArg0C_n = v48_n;
						di_si_n = di_si_n;
						if (v48_n < 0x00)
							goto l0800_n;
						struct Eq_n Eq_n::* sp_n = sp_n - 2;
						(ss->*sp_n).pseg0000 = wArg08;
						(ss->*sp_n).wFFFFFFFE = wArg06;
						(seg0800->*wArg02)();
						++wLoc06_n;
						word16 sp_n;
						sp_n = sp_n + 4;
						goto l0800_nC8;
					}
				}
				wArg0A = 0x10;
l0800_nC:
				di_si_n = 0x00;
				goto l0800_nB5;
			}
			goto l0800_nB;
		}
		goto l0800_nE;
	}
	ax_n = ax_n;
	if (wArg0A > 0x24)
		goto l0800_n;
	ax_n = ax_n;
	if (cl_n >= 0x02)
	{
		if (al_n == 0x30)
		{
			if (cl_n != 0x10)
				goto l0800_nC;
			ci16 v35_n = wArg0C_n - 0x01;
			wArg0C_n = v35_n;
			if (v35_n >= 0x00)
			{
				struct Eq_n Eq_n::* sp_n = sp_n - 2;
				(ss->*sp_n).pseg0000 = wArg08;
				(ss->*sp_n).wFFFFFFFE = wArg06;
				(seg0800->*wArg02)();
				++wLoc06_n;
				byte al_n = (byte) ax_n;
				word16 sp_n;
				sp_n = sp_n + 4;
				if (al_n != 0x78 && al_n != 88)
				{
					di_si_n = 0x00;
					goto l0800_nC8;
				}
				goto l0800_nC;
			}
l0800_nB:
			di_si_n = 0x00;
			goto l0800_n;
		}
l0800_nE:
		Eq_n bx_n;
		ax_n = bx_n;
		if (!fn0800-9485((byte) wArg0A, (byte) ax_n, out bx_n))
		{
			di_si_n = (uint32) bx_n;
			goto l0800_nB5;
		}
		goto l0800_n;
	}
	goto l0800_n;
}

// 0800:9652: void fn0800-9652(Stack (ptr32 Eq_n) ptrArg02)
void fn0800-9652(struct Eq_n * ptrArg02)
{
	word16 dx_n = ptrArg02->w0002;
	msdos_set_system_date(ptrArg02->w0000, SLICE(dx_n, byte, 8), (byte) dx_n);
}

// 0800:9667: void fn0800-9667(Stack (ptr32 Eq_n) ptrArg02)
void fn0800-9667(struct Eq_n * ptrArg02)
{
	word16 cx_n = ptrArg02->w0000;
	word16 dx_n = ptrArg02->w0002;
	msdos_get_system_time((byte) cx_n, SLICE(cx_n, byte, 8), SLICE(dx_n, byte, 8), (byte) dx_n);
}

// 0800:9764: Sequence word32 fn0800-9764(Register Eq_n ds, Stack Eq_n ptrArg02, Register out word16 cxOut)
// Called from:
//      main
word32 fn0800-9764(Eq_n ds, Eq_n ptrArg02, word16 & cxOut)
{
	struct Eq_n * dx_n;
	word16 cx_n;
	<unknown> Eq_n::* fp;
	fn0800-8B95(fp - 6);
	fn0800-8BA8(fp - 0x0A);
	Eq_n ax_n = fn0800_C04F(ds, fp - 6, fp - 0x0A, out cx_n, out dx_n);
	if (ptrArg02 != 0x00)
	{
		ptrArg02.u5->t0002.u1.u2 = dx_n;
		ptrArg02.u5->t0000.u1.u2 = (uint16) ax_n;
	}
	cxOut = cx_n;
	return &(dx_n->*ax_n.u3);
}

// 0800:97B6: Sequence int32 fn0800-97B6(Register Eq_n ds, Stack Eq_n wArg02)
// Called from:
//      fn0800_AD2F
int32 fn0800-97B6(Eq_n ds, Eq_n wArg02)
{
	int16 dx_n;
	word16 cx_n;
	return SEQ(dx_n, fn0800-8E29(ds, wArg02, 0x00, 0x01, out cx_n, out dx_n));
}

// 0800:97CC: Register byte fn0800-97CC(Register Eq_n ds, Stack int16 wArg02, Register out int16 dxOut)
// Called from:
//      fn0800-0C29
//      fn0800-0C6C
byte fn0800-97CC(Eq_n ds, int16 wArg02, int16 & dxOut)
{
	uint8 dl_n = (byte) wArg02;
	uint16 ax_n;
	if (wArg02 == ~0x00)
		ax_n = ~0x00;
	else if ((Mem7[ds:CONVERT(dl_n, uint8, uint16) + 0x2251:byte] & 0x08) != 0x00)
		ax_n = (uint16) dl_n + ~0x1F;
	else
		ax_n = (uint16) dl_n;
	dxOut = wArg02;
	return (byte) ax_n;
}

// 0800:97F8: void fn0800-97F8(Register Eq_n ds, Stack (ptr32 char) ptrArg02)
// Called from:
//      fn0800_A614
void fn0800-97F8(Eq_n ds, char * ptrArg02)
{
	Eq_n ax_n;
	if (msdos_delete_file(ptrArg02, out ax_n))
		fn0800-8D2B(ds, ax_n);
}

// 0800:9810: Register word16 fn0800-9810(Sequence (ptr32 byte) es_di, Register byte dh, Register byte dl)
// Called from:
//      fn0800-9828
word16 fn0800-9810(byte * es_di, byte dh, byte dl)
{
	struct Eq_n * es = SLICE(es_di, selector, 16);
	word16 di_n = fn0800-9817(es_di, dh);
	return fn0800-9817(di_n, dl);
}

// 0800:9817: Register word16 fn0800-9817(Sequence (ptr32 byte) es_di, Register byte al)
// Called from:
//      fn0800-9810
word16 fn0800-9817(byte * es_di, byte al)
{
	struct Eq_n * es = SLICE(es_di, selector, 16);
	word16 ax_n = __aam(al);
	byte al_n = (byte) ax_n;
	word16 di_n = fn0800-9820(es_di, SLICE(ax_n, byte, 8));
	return fn0800-9820(di_n, al_n);
}

// 0800:9820: Register word16 fn0800-9820(Sequence (ptr32 byte) es_di, Register byte al)
// Called from:
//      fn0800-9817
word16 fn0800-9820(byte * es_di, byte al)
{
	word16 di = (word16) es_di;
	*es_di = (bool) __daa(al + 0x90, &(al + 0x90)) + (al + 0xD0);
	return di + 1;
}

// 0800:9828: Register word16 fn0800-9828(Register Eq_n cx, Register Eq_n dx, Register Eq_n bx, Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n ptrArg04, Register out word16 diOut)
// Called from:
//      fn0800_B2EF
//      fn0800_BEA2
word16 fn0800-9828(Eq_n cx, Eq_n dx, Eq_n bx, Eq_n ds, Eq_n wArg02, Eq_n ptrArg04, word16 & diOut)
{
	Eq_n fp;
	Eq_n bLoc16_n;
	bLoc16_n.u0 = 0x50;
	struct Eq_n Eq_n::* sp_n = fp - 0x9E;
	byte Eq_n::* wLoc06_n = fp - 0x98;
l0800_n:
	byte Eq_n::* di_n = wLoc06_n;
l0800_n:
	struct Eq_n * psegArg06_n = SLICE(ptrArg04, selector, 16);
	struct Eq_n * es_n = SLICE(ptrArg04, selector, 16);
	byte Eq_n::* si_n = (word16) ptrArg04;
	Eq_n ss;
	while (true)
	{
		Eq_n al_n = es_n->*si_n;
		++si_n;
		Eq_n al_n = al_n;
		if (al_n == 0x00)
			break;
		if (al_n == 0x25)
		{
			al_n = es_n->*si_n;
			++si_n;
			if (al_n == 0x25)
				goto l0800_nA5;
			wLoc06_n = di_n;
			cu8 ch_n = 0x00;
			Eq_n wLoc10_n;
			wLoc10_n.u0 = 0x00;
			cui16 wLoc04_n = 0x20;
			Eq_n bLoc0D_n;
			bLoc0D_n.u0 = 0x00;
			Eq_n wLoc0A_n;
			wLoc0A_n.u0 = ~0x00;
			Eq_n wLoc0C_n;
			wLoc0C_n.u0 = ~0x00;
l0800_nDD:
			Eq_n ax_n;
			ax_n.u2 = (uint16) al_n;
			uint8 bl_n = al_n - 0x20;
			byte ah_n = 0x00;
			dx = ax_n;
			bx.u2 = (uint16) bl_n;
			cx = SEQ(ch_n, 0x00);
			if (bl_n < 0x60)
			{
				uint8 bl_n = (uint8) (ds->*((word32) bx + 9733));
				bx.u2 = (uint16) bl_n;
				cx = SEQ(ch_n, 0x00);
				if (bx > 0x17)
					goto l0800_nC82;
				bx <<= 0x01;
				cx = SEQ(ch_n, 0x00);
				switch (bx)
				{
				case 0x00:
					cx = SEQ(ch_n, 0x00);
					if (ch_n <= 0x00)
					{
						if (bLoc0D_n != 0x2B)
							bLoc0D_n = al_n;
						goto l0800_nDB;
					}
					break;
				case 0x01:
					cx = SEQ(ch_n, 0x00);
					if (ch_n <= 0x00)
					{
						wLoc04_n |= 0x01;
						goto l0800_nDB;
					}
					break;
				case 0x02:
					Eq_n ax_n;
					ax_n.u2 = (ss->*wArg02.u5).t0000.u1.u2;
					ah_n = SLICE(ax_n, byte, 8);
					wArg02.u3 = &wArg02.u5->t0002.u0;
					if (ch_n >= 0x02)
					{
						cx = SEQ(ch_n, 0x00);
						if (ch_n != 0x04)
							goto l0800_n;
						wLoc0C_n = ax_n;
						++ch_n;
						goto l0800_nDB;
					}
					else
					{
						Eq_n ax_n = ax_n;
						if (ax_n < 0x00)
						{
							ax_n = -ax_n;
							wLoc04_n |= 0x02;
						}
						wLoc0A_n = ax_n;
						ch_n = 0x03;
						goto l0800_nA;
					}
				case 0x03:
					cx = SEQ(ch_n, 0x00);
					if (ch_n <= 0x00)
					{
						wLoc04_n |= 0x02;
						goto l0800_nDB;
					}
					break;
				case 0x04:
					cx = SEQ(ch_n, 0x00);
					if (ch_n >= 0x04)
						goto l0800_n;
					ch_n = 0x04;
					wLoc0C_n.u3 = &wLoc0C_n.u5->b0001;
					goto l0800_nDB;
				case 0x05:
					goto l0800_n;
				case 0x06:
					wLoc04_n |= 0x10;
					goto l0800_n;
				case 0x07:
					wLoc04_n |= 0x0100;
					goto l0800_nD1;
				case 0x08:
l0800_nD1:
					wLoc04_n &= ~0x10;
					goto l0800_n;
				case 0x09:
					if (ch_n <= 0x00)
					{
						if ((wLoc04_n & 0x02) == 0x00)
						{
							wLoc04_n |= 0x08;
							ch_n = 0x01;
							goto l0800_nDB;
						}
					}
					else
					{
l0800_n:
						Eq_n ax_n;
						ax_n.u3 = (int16) (al_n - 0x30);
						ah_n = 0x00;
						if (ch_n <= 0x02)
						{
							ch_n = 0x02;
							wLoc0A_n = ax_n;
							if (wLoc0A_n >= 0x00)
							{
								wLoc0A_n.u3 = ax_n.u3 + wLoc0A_n *16 0x0A;
								goto l0800_nDB;
							}
						}
						else
						{
							cx = SEQ(ch_n, 0x00);
							if (ch_n != 0x04)
							{
l0800_n:
								goto l0800_nC82;
							}
							wLoc0C_n = ax_n;
							if (wLoc0C_n != 0x00)
							{
								wLoc0C_n.u3 = ax_n.u3 + wLoc0C_n *16 0x0A;
								goto l0800_nDB;
							}
						}
					}
l0800_nA:
					goto l0800_nDB;
				case 0x0A:
					uint8 bLoc08_n = 0x01;
					Eq_n ax_n;
					ax_n.u2 = (ss->*wArg02.u5).t0000.u1.u2;
					Eq_n bx_n = SEQ(0x0A, bl_n << 0x01);
					goto l0800_nA0A;
				case 11:
					Eq_n bx_n = SEQ(0x08, bl_n << 0x01);
					goto l0800_nE6;
				case 0x0C:
					Eq_n bx_n = SEQ(0x0A, bl_n << 0x01);
					goto l0800_nEA;
				case 0x0D:
					bx_n = SEQ(0x10, (byte) al_n + 233);
l0800_nE6:
					bLoc0D_n.u0 = 0x00;
					bx_n = bx_n;
l0800_nEA:
					bLoc08_n = 0x00;
					ax_n.u2 = (ss->*wArg02.u5).t0000.u1.u2;
					bx_n = bx_n;
l0800_nA0A:
					struct Eq_n Eq_n::* di_n = (struct Eq_n Eq_n::*) &wArg02.u5->b0001;
					int8 bh_n = SLICE(bx_n, byte, 8);
					Eq_n dx_n;
					dx_n.u0 = 0x00;
					Eq_n di_n;
					di_n.u3 = &di_n->t0001.u0;
					ptrArg04.u3 = &(psegArg06_n->*si_n);
					if ((wLoc04_n & 0x10) != 0x00)
					{
						dx_n.u2 = (ss->*di_n).t0001.u2;
						di_n.u3 = di_n + 1;
					}
					wArg02 = di_n;
					if (ax_n == 0x00)
					{
						dx = dx_n;
						if (dx_n != 0x00)
							goto l0800_nA32;
						bx = bx_n;
						if (wLoc0C_n == 0x00)
							goto l0800_n;
					}
					else
					{
l0800_nA32:
						wLoc04_n |= 0x04;
					}
					struct Eq_n Eq_n::* sp_n = sp_n - 2;
					(ss->*sp_n).t0000.u2 = (uint16) dx_n;
					(ss->*sp_n).tFFFFFFFE.u2 = (uint16) ax_n;
					(ss->*sp_n).tFFFFFFFC.u2 = (uint16) ss;
					(ss->*sp_n).tFFFFFFFA.u2 = (uint16) (fp - 71);
					(ss->*sp_n).tFFFFFFF8.u0 = (int16) bh_n;
					(ss->*sp_n).tFFFFFFF6.u2 = (uint16) bLoc08_n;
					(ss->*sp_n).tFFFFFFF4.u2 = (uint16) bx_n;
					fn0800-8D87((ss->*sp_n).tFFFFFFF4.u0, (ss->*sp_n).tFFFFFFF6.u0, (ss->*sp_n).tFFFFFFF8.u0, (ss->*sp_n).tFFFFFFFA.u3, (ss->*sp_n).tFFFFFFFE.u3);
					(ss->*sp_n).t0000.u2 = (uint16) ss;
					Eq_n es_n;
					es_n.u6 = (ss->*sp_n).t0000.u6;
					sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0000 + 2);
					dx = wLoc0C_n;
					byte * es_di_n;
					byte * es_di_n;
					if (wLoc0C_n >= 0x00)
					{
						es_di_n = SEQ(es_n, fp - 71);
						goto l0800_nB54;
					}
					else
					{
						es_di_n = SEQ(es_n, fp - 71);
						goto l0800_nB46;
					}
				case 0x0E:
					struct Eq_n Eq_n::* sp_n = sp_n - 2;
					(ss->*sp_n).t0000.u2 = (ss->*wArg02.u5).t0000.u1.u2;
					byte Eq_n::* di_n = fp - 72;
					wArg02.u3 = &wArg02.u5->t0002.u0;
					ptrArg04.u3 = &(psegArg06_n->*si_n);
					if ((wLoc04_n & 0x20) != 0x00)
					{
						word16 dx_n = (ss->*wArg02.u5).t0002.u1.u2;
						(ss->*sp_n).tFFFFFFFE.u2 = (uint16) ss;
						Eq_n es_n;
						es_n.u6 = (ss->*sp_n).tFFFFFFFE.u6;
						byte Eq_n::* di_n = fn0800-9810(SEQ(es_n, fp - 72), SLICE(dx_n, byte, 8), (byte) dx_n);
						es_n->*di_n = 0x3A;
						wArg02.u3 = &wArg02.u5->t0004.u0;
						di_n = di_n + 1;
					}
					(ss->*sp_n).tFFFFFFFE.u2 = (uint16) ss;
					Eq_n dx_n;
					dx_n.u2 = (ss->*sp_n).t0000.u2;
					Eq_n es_n;
					es_n.u6 = (ss->*sp_n).tFFFFFFFE.u6;
					byte Eq_n::* di_n = fn0800-9810(SEQ(es_n, di_n), SLICE(dx_n, byte, 8), (byte) dx_n);
					ss->*di_n = 0x00;
					sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0000 + 2);
					wLoc04_n &= ~0x04;
					Eq_n di_n = di_n - (fp - 72);
					dx = wLoc0C_n;
					if (wLoc0C_n <= di_n)
						dx = di_n;
					es_di_n = SEQ(es_n, fp - 72);
					goto l0800_nB46;
				case 0x0F:
					Eq_n cx_n = wLoc0C_n;
					ptrArg04.u3 = &(psegArg06_n->*si_n);
					if (wLoc0C_n < 0x00)
						cx_n.u0 = 0x06;
					struct Eq_n Eq_n::* sp_n = sp_n - 2;
					(ss->*sp_n).t0000.u2 = (uint16) ss;
					(ss->*sp_n).tFFFFFFFE.u2 = (uint16) wArg02;
					(ss->*sp_n).tFFFFFFFC.u2 = (uint16) cx_n;
					(ss->*sp_n).tFFFFFFFA.u2 = (uint16) ss;
					(ss->*sp_n).tFFFFFFF8.u0 = (int16) (fp - 71);
					(ss->*sp_n).tFFFFFFF6.u2 = (uint16) ax_n;
					(ss->*sp_n).tFFFFFFF4.u2 = (uint16) (wLoc04_n & 0x01);
					word16 ax_n;
					if ((wLoc04_n & 0x0100) != 0x00)
					{
						ax_n = 0x08;
						wArg02.u3 = &wArg02.u5->t000A.u0;
					}
					else
					{
						wArg02.u3 = &wArg02.u5->t0008.u0;
						ax_n = 0x06;
					}
					(ss->*sp_n).wFFFFFFF2 = ax_n;
					fn0800_A2CC(ds);
					(ss->*sp_n).tFFFFFFF0.u2 = (uint16) ss;
					sp_n = sp_n - 0x0E;
					es_di_n = SEQ((ss->*sp_n).tFFFFFFF0.u6, fp - 71);
l0800_nB46:
					Eq_n es_n;
					es_n.u3 = SLICE(es_di_n, selector, 16);
					byte Eq_n::* di_n = (word16) es_di_n;
					if ((wLoc04_n & 0x08) != 0x00)
					{
						dx = wLoc0A_n;
						es_di_n = es_di_n;
						if (wLoc0A_n > 0x00)
						{
l0800_nB54:
							es_n.u3 = SLICE(es_di_n, selector, 16);
							di_n = (word16) es_di_n;
							Eq_n cx_n = fn0800-9842(di_n, es_n);
							if (*es_di_n == 0x2D)
								--cx_n;
							dx -= cx_n;
							if (dx > 0x00)
								wLoc10_n = dx;
						}
					}
					if (es_n->*di_n != 0x2D)
					{
						if (bLoc0D_n == 0x00)
							goto l0800_nB86;
						--di_n;
						es_n->*di_n = (byte) bLoc0D_n;
					}
					if (wLoc10_n > 0x00 && wLoc0C_n < 0x00)
						--wLoc10_n;
l0800_nB86:
					Eq_n cx_n = fn0800-9842(di_n, es_n);
					goto l0800_nB89;
				case 0x10:
					union Eq_n Eq_n::* sp_n = sp_n - 2;
					(ss->*sp_n).u2 = (uint16) ss;
					wArg02.u3 = &wArg02.u5->t0002.u0;
					es_n.u6 = (ss->*sp_n).u6;
					sp_n = (struct Eq_n Eq_n::*) ((char *) sp_n + 2);
					di_n = fp - 71;
					cx_n.u0 = 0x01;
					ptrArg04.u3 = &(psegArg06_n->*si_n);
					goto l0800_nB89;
				case 0x11:
					ptrArg04.u3 = &(psegArg06_n->*si_n);
					bool v73_n;
					if ((wLoc04_n & 0x20) == 0x00)
					{
						byte Eq_n::* di_n = (byte Eq_n::*) (ss->*wArg02.u5).t0000.u1.u2;
						union Eq_n Eq_n::* sp_n = sp_n - 2;
						(ss->*sp_n).u2 = (uint16) ds;
						wArg02.u3 = &wArg02.u5->t0002.u0;
						es_n.u6 = (ss->*sp_n).u6;
						di_n = di_n;
						v73_n = di_n != 0x00;
					}
					else
					{
						Eq_n es_di_n = (ds->*wArg02.u5).t0000.u1.u3;
						es_n.u3 = SLICE(es_di_n, selector, 16);
						di_n = (word16) es_di_n;
						wArg02.u3 = &wArg02.u5->t0004.u0;
						v73_n = es_di_n != 0x00;
					}
					if (!v73_n)
					{
						union Eq_n Eq_n::* sp_n = sp_n - 2;
						(ss->*sp_n).u2 = (uint16) ds;
						es_n.u6 = (ss->*sp_n).u6;
						di_n = 0x25FE;
					}
					cx_n = fn0800-9842(di_n, es_n);
					if (cx_n > wLoc0C_n)
						cx_n = wLoc0C_n;
l0800_nB89:
					byte Eq_n::* si_n = di_n;
					Eq_n bx_n = wLoc0A_n;
					if ((wLoc04_n & 0x05) == 0x05)
					{
						if (al_n != 111)
						{
							if (al_n == 0x78 || al_n == 88)
							{
								Eq_n v45_n = wLoc10_n - 0x02;
								wLoc04_n |= 0x40;
								bx_n = wLoc0A_n - 0x02;
								wLoc10_n = v45_n;
								if (v45_n < 0x00)
									wLoc10_n.u0 = 0x00;
							}
l0800_nBCC:
							cx.u3 = cx_n + wLoc10_n;
							if ((wLoc04_n & 0x02) == 0x00)
							{
								for (; bx_n > cx; --bx_n)
									fn0800-984F(SEQ(ss, fp - 2), 0x20, cx, dx, bx_n, di_n, out di_n);
							}
							if ((wLoc04_n & 0x40) != 0x00)
							{
								byte Eq_n::* di_n;
								fn0800-984F(SEQ(ss, fp - 2), 0x30, cx, dx, bx_n, di_n, out di_n);
								fn0800-984F(SEQ(ss, fp - 2), al_n, cx, dx, bx_n, di_n, out di_n);
							}
							dx = wLoc10_n;
							if (wLoc10_n > 0x00)
							{
								Eq_n cx_n = cx - wLoc10_n;
								bx_n -= wLoc10_n;
								Eq_n al_n = es_n->*di_n;
								if (al_n == 0x2D || (al_n == 0x20 || al_n == 0x2B))
								{
									fn0800-984F(SEQ(ss, fp - 2), es_n->*di_n, cx_n, wLoc10_n, bx_n, di_n, out di_n);
									si_n = di_n + 1;
									--cx_n;
									--bx_n;
								}
								Eq_n cx_n = wLoc10_n;
								if (wLoc10_n != 0x00)
								{
									do
									{
										fn0800-984F(SEQ(ss, fp - 2), 0x30, cx_n, cx_n, bx_n, di_n, out di_n);
										--cx_n;
									} while (cx_n != 0x00);
								}
								dx = cx_n;
								cx = cx_n;
							}
							if (cx != 0x00)
							{
								bx_n -= cx;
								do
								{
									ss->*di_n = es_n->*si_n;
									Eq_n v50_n = bLoc16_n - 0x01;
									++si_n;
									++di_n;
									bLoc16_n = v50_n;
									if (v50_n <= 0x00)
										fn0800-9858(SEQ(ss, fp - 2), cx, dx, bx_n, di_n, out di_n);
									--cx;
								} while (cx != 0x00);
							}
							bx = bx_n;
							if (bx_n > 0x00)
							{
								cx = bx_n;
								do
								{
									fn0800-984F(SEQ(ss, fp - 2), 0x20, cx, dx, bx_n, di_n, out di_n);
									--cx;
								} while (cx != 0x00);
							}
							goto l0800_n;
						}
						if (wLoc10_n <= 0x00)
							wLoc10_n.u0 = 0x01;
					}
					goto l0800_nBCC;
				case 0x12:
					ptrArg04.u3 = &(psegArg06_n->*si_n);
					struct Eq_n Eq_n::* di_n;
					Eq_n es_n;
					if ((wLoc04_n & 0x20) == 0x00)
					{
						di_n = (struct Eq_n Eq_n::*) (ss->*wArg02.u5).t0000.u1.u2;
						union Eq_n Eq_n::* sp_n = sp_n - 2;
						(ss->*sp_n).u2 = (uint16) ds;
						wArg02.u3 = &wArg02.u5->t0002.u0;
						es_n.u6 = (ss->*sp_n).u6;
					}
					else
					{
						segptr32 es_di_n = (ds->*wArg02.u5).t0000.u1.u3;
						es_n.u3 = SLICE(es_di_n, selector, 16);
						di_n = (word16) es_di_n;
						wArg02.u3 = &wArg02.u5->t0004.u0;
					}
					(es_n->*di_n).w0000 = (uint16) (0x50 - bLoc16_n);
					if ((wLoc04_n & 0x10) != 0x00)
						(es_n->*di_n).w0002 = 0x00;
					goto l0800_n;
				case 0x13:
				case 0x14:
				case 0x15:
					goto l0800_nC82;
				case 22:
					wLoc04_n &= ~0x20;
					goto l0800_n;
				case 0x17:
					wLoc04_n |= 0x20;
l0800_n:
					ch_n = 0x05;
l0800_nDB:
					al_n = es_n->*si_n;
					++si_n;
					goto l0800_nDD;
				}
			}
l0800_nC82:
			dx = ax_n;
			byte Eq_n::* si_n = si_n;
			uint16 ax_n = SEQ(ah_n, 0x25);
			uint8 al_n;
			do
			{
				uint16 ax_n = (uint16) al_n;
				fn0800-984F(SEQ(ss, fp - 2), (byte) ax_n, cx, ax_n, bx, di_n, out di_n);
				al_n = psegArg06_n->*si_n;
				++si_n;
				ax_n = ax_n;
			} while (al_n != 0x00);
			break;
		}
l0800_nA5:
		ss->*di_n = (byte) al_n;
		Eq_n v18_n = bLoc16_n - 0x01;
		++di_n;
		bLoc16_n = v18_n;
		if (v18_n <= 0x00)
			fn0800-9858(SEQ(ss, fp - 2), cx, dx, bx, di_n, out di_n);
	}
	if (bLoc16_n < 0x50)
	{
		word16 di_n;
		fn0800-9858(SEQ(ss, fp - 2), cx, dx, bx, di_n, out di_n);
	}
	struct Eq_n Eq_n::* sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0000 + 2);
	word16 si_n = (ss->*sp_n).w0002;
	diOut = (ss->*sp_n).w0000;
	return si_n;
}

// 0800:9842: Register word16 fn0800-9842(Register (memptr Eq_n byte) di, Register Eq_n es)
// Called from:
//      fn0800-9828
word16 fn0800-9842(byte Eq_n::* di, Eq_n es)
{
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		byte Eq_n::* di_n;
		di = di_n + 1;
		--cx_n;
		di_n = di;
		if (es->*di_n != 0x00)
			return -cx_n;
	}
	return -cx_n;
}

// 0800:984F: Register byte fn0800-984F(Sequence (ptr32 Eq_n) ss_bp, Register Eq_n al, Register Eq_n cx, Register Eq_n dx, Register Eq_n bx, Register (memptr Eq_n byte) di, Register out (memptr Eq_n byte) diOut)
// Called from:
//      fn0800-9828
byte fn0800-984F(struct Eq_n * ss_bp, Eq_n al, Eq_n cx, Eq_n dx, Eq_n bx, byte Eq_n::* di, byte & diOut)
{
	word16 ax;
	al = (byte) ax;
	Eq_n ss;
	ss.u3 = SLICE(ss_bp, selector, 16);
	ss->*di = (byte) al;
	Eq_n v9_n = ss_bp->tFFFFFFEC.u0 - 0x01;
	ss_bp->tFFFFFFEC.u0 = (byte) v9_n;
	if (v9_n != 0x00)
	{
		diOut = di + 1;
		return SLICE(ax, byte, 8);
	}
	else
	{
		byte Eq_n::* di_n;
		fn0800-9858(ss_bp, cx, dx, bx, di + 1, out di_n);
		diOut = di_n;
		return 0x00;
	}
}

// 0800:9858: Register byte fn0800-9858(Sequence (ptr32 Eq_n) ss_bp, Register Eq_n cx, Register Eq_n dx, Register Eq_n bx, Register (memptr Eq_n byte) di, Register out (memptr Eq_n byte) diOut)
// Called from:
//      fn0800-9828
//      fn0800-984F
byte fn0800-9858(struct Eq_n * ss_bp, Eq_n cx, Eq_n dx, Eq_n bx, byte Eq_n::* di, byte & diOut)
{
	word16 bp = (word16) ss_bp;
	word16 di_n = di - (bp - 0x96);
	selector seg0800;
	(seg0800->*ss_bp->ptr000E)();
	word16 ax_n;
	if (ax_n == 0x00)
		ss_bp->wFFFFFFEA = 0x01;
	ss_bp->tFFFFFFEC.u1 = 0x50;
	ss_bp->wFFFFFFEE += di_n;
	diOut = bp - 0x96;
	return SLICE(ax_n, byte, 8);
}

// 0800:9CE6: Sequence word32 fn0800-9CE6(Stack Eq_n dwArg02, Stack Eq_n dwArg06)
// Called from:
//      fn0800-8E6A
word32 fn0800-9CE6(Eq_n dwArg02, Eq_n dwArg06)
{
	word16 cx_n;
	word16 wArg04 = SLICE(dwArg02, word16, 16);
	word16 wArg02 = (word16) dwArg02;
	Eq_n ax_n = fn0800_BFC7(dwArg06, out cx_n);
	fn0800_B03B(dwArg02, dwArg06, (word32) ax_n + 1);
	return SEQ(wArg04, (word32) ax_n + wArg02);
}

// 0800:9D41: Register byte fn0800-9D41(Register Eq_n dx, Register out word16 cxOut, Register out word16 dxOut, Register out word16 bxOut)
// Called from:
//      fn0800-9E75
byte fn0800-9D41(Eq_n dx, word16 & cxOut, word16 & dxOut, word16 & bxOut)
{
	selector seg0800;
	if (dx != seg0800->tFFFF9D35)
	{
		Eq_n ds_n = Mem0[dx:0x02:selector];
		Eq_n ds_n;
		Eq_n wLoc02_n;
		if (Mem0[ds_n:0x02:word16] != 0x00)
		{
			seg0800->tFFFF9D37 = ds_n;
l0800_nD94:
			ds_n = seg0800->tFFFF9D3B;
			wLoc02_n = dx;
			goto l0800_nD9D;
		}
		if (ds_n != seg0800->tFFFF9D35)
		{
			Mem20[0800:9D37:word16] = Mem0[ds_n:0x08:word16];
			fn0800-9E15(ds_n);
			wLoc02_n = ds_n;
			ds_n = seg0800->tFFFF9D3B;
l0800_nD9D:
			word16 cx_n;
			word16 dx_n;
			word16 bx_n;
			fn0800_A1D6(ds_n, 0x00, wLoc02_n, out cx_n, out dx_n, out bx_n);
			cxOut = cx_n;
			dxOut = dx_n;
			bxOut = bx_n;
			return 0x00;
		}
		dx = seg0800->tFFFF9D35;
	}
	seg0800->tFFFF9D35.u0 = 0x00;
	seg0800->tFFFF9D37.u0 = 0x00;
	seg0800->tFFFF9D39.u0 = 0x00;
	goto l0800_nD94;
}

// 0800:9DA4: Register byte fn0800-9DA4(Register Eq_n dx, Register out Eq_n bxOut)
// Called from:
//      fn0800-9E75
byte fn0800-9DA4(Eq_n dx, union Eq_n & bxOut)
{
	Eq_n es_n = Mem8[dx:0x02:selector];
	Mem10[dx:0x02:word16] = 0x00;
	Mem11[dx:0x08:word16] = es_n;
	Eq_n wLoc02_n = dx;
	selector seg0800;
	Eq_n bx_n;
	if (dx != seg0800->tFFFF9D35 && Mem11[es_n:0x02:word16] == 0x00)
	{
		Eq_n ax_n = Mem11[dx:0x00:word16];
		Mem32[es_n:0x00:word16] = Mem30[es_n:0x00:word16] + ax_n;
		bx_n = dx;
		wLoc02_n = es_n;
		struct Eq_n * dx_n = dx + ax_n;
		if (dx_n->t0002 == 0x00)
			dx_n->t0008 = es_n;
		else
			dx_n->t0002 = es_n;
	}
	else
		bx_n = fn0800-9E3E(dx);
	Eq_n ax_n = wLoc02_n + Mem44[wLoc02_n:0x00:word16];
	if (Mem44[ax_n:0x02:word16] == 0x00)
	{
		Mem55[wLoc02_n:0x00:word16] = Mem44[wLoc02_n:0x00:word16] + Mem44[ax_n:0x00:word16];
		(ax_n + Mem55[ax_n:0x00:word16])->t0002 = wLoc02_n;
		bxOut = fn0800-9E15(ax_n);
		return SLICE(wLoc02_n, byte, 8);
	}
	else
	{
		bxOut = bx_n;
		return SLICE(ax_n, byte, 8);
	}
}

// 0800:9E15: Register word16 fn0800-9E15(Register Eq_n ds)
// Called from:
//      fn0800-9D41
//      fn0800-9DA4
//      fn0800-9F89
word16 fn0800-9E15(Eq_n ds)
{
	selector seg0800;
	if (ds == Mem0[ds:0x06:word16])
	{
		seg0800->tFFFF9D39.u0 = 0x00;
		return;
	}
	else
	{
		Eq_n es_n = Mem0[ds:0x06:selector];
		Eq_n ds_n = Mem0[ds:0x04:selector];
		Mem12[ds_n:0x06:word16] = es_n;
		Mem13[es_n:0x04:word16] = ds_n;
		seg0800->tFFFF9D39 = ds_n;
		return;
	}
}

// 0800:9E3E: Register (ptr16 Eq_n) fn0800-9E3E(Register Eq_n ds)
// Called from:
//      fn0800-9DA4
struct Eq_n * fn0800-9E3E(Eq_n ds)
{
	selector seg0800;
	Eq_n ax_n = seg0800->tFFFF9D39;
	if (ax_n == 0x00)
	{
		seg0800->tFFFF9D39 = ds;
		Mem13[ds:0x04:word16] = ds;
		Mem14[ds:0x06:word16] = ds;
		struct Eq_n * bx;
		return bx;
	}
	else
	{
		__cli();
		Eq_n es_n = Mem21[ax_n:0x06:selector];
		Mem24[ax_n:0x06:word16] = ds;
		Mem25[ds:0x04:word16] = ax_n;
		Mem29[es_n:0x04:word16] = ds;
		Mem30[ds:0x06:word16] = es_n;
		struct Eq_n * ss;
		return ss;
	}
}

// 0800:9E75: Register byte fn0800-9E75(Register Eq_n ds, Stack Eq_n wArg04, Register out word16 cxOut, Register out Eq_n dxOut, Register out word16 bxOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-4346
//      fn0800_A006
//      fn0800_A080
//      fn0800_A614
//      fn0800_BA89
byte fn0800-9E75(Eq_n ds, Eq_n wArg04, word16 & cxOut, union Eq_n & dxOut, word16 & bxOut, union Eq_n & dsOut)
{
	selector seg0800;
	seg0800->tFFFF9D3B = ds;
	Eq_n dx_n = wArg04;
	uint16 ax;
	word16 cx;
	word16 bx;
	if (wArg04 != 0x00)
	{
		if (wArg04 == seg0800->tFFFF9D37)
			ax = (uint16) fn0800-9D41(wArg04, out cx, out dx_n, out bx);
		else
			ax = (uint16) fn0800-9DA4(wArg04, out bx);
	}
	Eq_n ds_n = seg0800->tFFFF9D3B;
	cxOut = cx;
	dxOut = dx_n;
	bxOut = bx;
	dsOut = ds_n;
	return SLICE(ax, byte, 8);
}

// 0800:9E9E: Register Eq_n fn0800-9E9E(Register Eq_n ax, Register out Eq_n dxOut)
// Called from:
//      fn0800-9F89
Eq_n fn0800-9E9E(Eq_n ax, union Eq_n & dxOut)
{
	word16 dx_n;
	selector seg0800;
	cui16 ax_n = fn0800_A215(seg0800->tFFFF9D3B, 0x00, out dx_n);
	if ((ax_n & 0x0F) != 0x00)
	{
		word16 dx_n;
		fn0800_A215(seg0800->tFFFF9D3B, (uint32) (0x10 - (ax_n & 0x0F)), out dx_n);
	}
	Eq_n dx_n;
	if (fn0800_A215(seg0800->tFFFF9D3B, SEQ((uint16) SLICE(ax, byte, 8) >> 0x04, ax << 0x04), out dx_n) == ~0x00)
	{
		dxOut.u0 = 0x00;
		return 0x00;
	}
	else
	{
		seg0800->tFFFF9D35 = dx_n;
		seg0800->tFFFF9D37 = dx_n;
		Mem97[dx_n:0x00:word16] = ax;
		Mem98[dx_n:0x02:word16] = dx_n;
		dxOut = dx_n;
		return 0x04;
	}
}

// 0800:9F02: Register Eq_n fn0800-9F02(Register Eq_n ax, Register out Eq_n dxOut)
// Called from:
//      fn0800-9F89
Eq_n fn0800-9F02(Eq_n ax, union Eq_n & dxOut)
{
	Eq_n dx_n;
	selector seg0800;
	uint8 ah_n = SLICE(ax, byte, 8);
	Eq_n ds_n = seg0800->tFFFF9D3B;
	cui16 ax_n = fn0800_A215(ds_n, SEQ((uint16) ah_n >> 0x04, ax << 0x04), out dx_n);
	if (ax_n != ~0x00)
	{
		if ((ax_n & 0x0F) == 0x00)
		{
l0800_nF25:
			Eq_n cx_n = seg0800->tFFFF9D37;
			seg0800->tFFFF9D37 = dx_n;
			Mem84[dx_n:0x00:word16] = ax;
			Mem85[dx_n:0x02:word16] = cx_n;
			dxOut = dx_n;
			return 0x04;
		}
		word16 dx_n;
		if (fn0800_A215(ds_n, (uint32) (-(ax_n & 0x0F) + 0x10), out dx_n) != ~0x00)
		{
			dx_n.u3 = &dx_n.u5->b0001;
			goto l0800_nF25;
		}
	}
	dxOut.u0 = 0x00;
	return 0x00;
}

// 0800:9F5C: Register Eq_n fn0800-9F5C(Register Eq_n ax, Register Eq_n dx, Register Eq_n ds, Register out (ptr16 Eq_n) dxOut)
// Called from:
//      fn0800-9F89
Eq_n fn0800-9F5C(Eq_n ax, Eq_n dx, Eq_n ds, struct Eq_n & dxOut)
{
	Mem10[ds:0x00:word16] = Mem0[ds:0x00:word16] - ax;
	struct Eq_n * dx_n = dx + Mem10[ds:0x00:word16];
	dx_n->t0000 = ax;
	dx_n->t0002 = dx;
	(dx_n + Mem14[dx_n:0x00:word16])->ptr0002 = dx_n;
	dxOut = dx_n;
	return 0x04;
}

// 0800:9F7F: Register word16 fn0800-9F7F(Register Eq_n ds, Stack Eq_n wArg02, Register out word16 dxOut, Register out (memptr (ptr16 Eq_n) Eq_n) bpOut, Register out cup16 siOut, Register out word16 diOut, Register out (ptr16 Eq_n) dsOut)
// Called from:
//      fn0800_BA89
word16 fn0800-9F7F(Eq_n ds, Eq_n wArg02, word16 & dxOut, struct Eq_n & bpOut, cup16 & siOut, word16 & diOut, struct Eq_n & dsOut)
{
	struct Eq_n * ds_n;
	word16 di_n;
	cup16 si_n;
	struct Eq_n Eq_n::* bp_n;
	word16 dx_n;
	word16 ax_n = fn0800-9F92((uint32) wArg02, ds, out dx_n, out bp_n, out si_n, out di_n, out ds_n);
	dxOut = dx_n;
	bpOut = bp_n;
	siOut = si_n;
	diOut = di_n;
	dsOut = ds_n;
	return ax_n;
}

// 0800:9F89: Register word16 fn0800-9F89(Register Eq_n ds, Stack Eq_n dwArg02, Register out word16 dxOut, Register out word16 bpOut, Register out word16 siOut, Register out (ptr16 Eq_n) dsOut)
// Called from:
//      fn0800-4311
//      fn0800_A006
word16 fn0800-9F89(Eq_n ds, Eq_n dwArg02, word16 & dxOut, word16 & bpOut, word16 & siOut, struct Eq_n & dsOut)
{
	struct Eq_n * ds_n;
	word16 di_n;
	word16 si_n;
	word16 bp_n;
	word16 dx_n;
	word16 ax_n = fn0800-9F92(dwArg02, ds, out dx_n, out bp_n, out si_n, out di_n, out ds_n);
	dxOut = dx_n;
	bpOut = bp_n;
	siOut = si_n;
	dsOut = ds_n;
	return ax_n;
}

// 0800:9F92: Register word16 fn0800-9F92(Sequence Eq_n dx_ax, Register Eq_n ds, Register out word16 dxOut, Register out word16 bpOut, Register out word16 siOut, Register out word16 diOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-9F7F
//      fn0800-9F89
word16 fn0800-9F92(Eq_n dx_ax, Eq_n ds, word16 & dxOut, word16 & bpOut, word16 & siOut, word16 & diOut, union Eq_n & dsOut)
{
	Eq_n ds_n;
	word16 di_n;
	word16 si_n;
	word16 bp_n;
	word16 dx_n;
	word16 ax = (word16) dx_ax;
	word16 dx = SLICE(dx_ax, word16, 16);
	selector seg0800;
	seg0800->tFFFF9D3B = ds;
	if (dx_ax == 0x00)
	{
		Eq_n ds_n = seg0800->tFFFF9D3B;
		dxOut = dx;
		word16 wArg00;
		bpOut = wArg00;
		word16 si;
		siOut = si;
		word16 di;
		diOut = di;
		dsOut = ds_n;
		return ax;
	}
	else
	{
		word16 ax_n = fn0800-9F9F(dx_ax, out dx_n, out bp_n, out si_n, out di_n, out ds_n);
		dxOut = dx_n;
		bpOut = bp_n;
		siOut = si_n;
		diOut = di_n;
		dsOut = ds_n;
		return ax_n;
	}
}

// 0800:9F9F: Register cu16 fn0800-9F9F(Sequence Eq_n dx_ax, Register out Eq_n dxOut, Register out word16 bpOut, Register out word16 siOut, Register out word16 diOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-9F89
//      fn0800-9F92
cu16 fn0800-9F9F(Eq_n dx_ax, union Eq_n & dxOut, word16 & bpOut, word16 & siOut, word16 & diOut, union Eq_n & dsOut)
{
	cu16 ax = (word16) dx_ax;
	cu16 dx_n = SLICE((word32) dx_ax + 19, word16, 16);
	selector seg0800;
	Eq_n dx_n;
	cu16 ax_n;
	if (dx_n >= 0x00 && (dx_n & ~0x0F) == 0x00)
	{
		Eq_n ax_n = SEQ(SLICE(ax + 0x13 >> 0x04, byte, 8) | (byte) dx_n << 0x04, (byte) (ax + 0x13 >> 0x04));
		if (seg0800->tFFFF9D35 != 0x00)
		{
			Eq_n dx_n = seg0800->tFFFF9D39;
			dx_n = dx_n;
			if (dx_n != 0x00)
			{
				do
				{
					if (Mem0[dx_n:0x00:word16] >=u ax_n)
					{
						if (Mem0[dx_n:0x00:word16] <=u ax_n)
						{
							fn0800-9E15(dx_n);
							Mem75[dx_n:0x02:word16] = Mem0[dx_n:0x08:word16];
							ax_n = 0x04;
						}
						else
							ax_n = fn0800-9F5C(ax_n, dx_n, dx_n, out dx_n);
						goto l0800_nFFD;
					}
					dx_n = Mem0[dx_n:0x06:word16];
				} while (dx_n != dx_n);
			}
			ax_n = fn0800-9F02(ax_n, out dx_n);
		}
		else
			ax_n = fn0800-9E9E(ax_n, out dx_n);
	}
	else
	{
		ax_n = 0x00;
		dx_n.u0 = 0x00;
	}
l0800_nFFD:
	Eq_n ds_n = seg0800->tFFFF9D3B;
	dxOut = dx_n;
	word16 wArg04;
	bpOut = wArg04;
	word16 wArg02;
	siOut = wArg02;
	word16 wArg00;
	diOut = wArg00;
	dsOut = ds_n;
	return ax_n;
}

// 0800:A006: void fn0800_A006(Register Eq_n bx, Register Eq_n ds)
void fn0800_A006(Eq_n bx, Eq_n ds)
{
	selector seg0800;
	struct Eq_n * dx_n;
	word16 bp_n;
	word16 si_n;
	selector ds_n;
	fn0800-9F89(ds, SEQ(seg0800->wFFFF9D3D, seg0800->wFFFF9D3F), out dx_n, out bp_n, out si_n, out ds_n);
	if (dx_n == 0x00)
		return;
	Eq_n dx_n = Mem42[bx:0x00:word16];
	memcpy(*((char *) dx_n + 4), bx.u5->t0004.u1.u3, 0x0C);
	cu16 dx_n = dx_n - 0x01;
	if (dx_n != 0x01)
	{
		struct Eq_n * es_n = (struct Eq_n *) ((char *) dx_n + 1);
		struct Eq_n * ds_n = (struct Eq_n *) &bx.u5->b0001;
		while (true)
		{
			cu16 cx_n = dx_n;
			if (dx_n > 0x1000)
				cx_n = 0x1000;
			memcpy(*es_n, *ds_n, (cx_n << 0x03) *32 0x02);
			dx_n -= 0x1000;
			if (dx_n <= 0x00)
				break;
			es_n = (struct Eq_n *) ((char *) es_n + 0x00001000);
			ds_n = (struct Eq_n *) ((char *) ds_n + 0x00001000);
		}
	}
	word16 cx_n;
	word16 dx_n;
	word16 bx_n;
	selector ds_n;
	fn0800-9E75(seg0800->tFFFF9D3B, bx, out cx_n, out dx_n, out bx_n, out ds_n);
}

// 0800:A080: void fn0800_A080(Register Eq_n ax, Register int16 cx, Register Eq_n bx, Register Eq_n ds)
void fn0800_A080(Eq_n ax, int16 cx, Eq_n bx, Eq_n ds)
{
	selector seg0800;
	if (bx == seg0800->tFFFF9D37)
	{
		Mem13[bx:0x00:word16] = ax;
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		fn0800_A1D6(ds, 0x00, bx + ax, out cx_n, out dx_n, out bx_n);
	}
	else
	{
		Eq_n di_n;
		di_n.u3 = bx + ax;
		Mem44[di_n:0x00:word16] = cx - ax;
		Mem45[di_n:0x02:word16] = bx;
		Mem51[bx:0x00:word16] = ax;
		struct Eq_n * dx_n = (struct Eq_n *) (bx.u3 + cx);
		if (dx_n->t0002 != 0x00)
			dx_n->t0002 = di_n;
		else
			dx_n->t0008 = di_n;
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		selector ds_n;
		fn0800-9E75(ds, di_n, out cx_n, out dx_n, out bx_n, out ds_n);
	}
}

// 0800:A162: Register word16 fn0800_A162(Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n wArg04, Register out cu16 cxOut, Register out Eq_n dxOut, Register out word16 bxOut)
// Called from:
//      fn0800_A1D6
//      fn0800_A215
word16 fn0800_A162(Eq_n ds, Eq_n wArg02, Eq_n wArg04, cu16 & cxOut, union Eq_n & dxOut, word16 & bxOut)
{
	word16 bx;
	byte ch;
	cu16 si_n = wArg04 + 0x01 - Mem11[ds:0x7B:word16];
	cu16 cx_n = SEQ(ch, 0x06);
	Eq_n dx_n;
	word16 ax_n;
	if (si_n + 0x3F >>u 0x06 != Mem11[ds:9880:word16])
	{
		cu16 si_n = __align(si_n + 0x3F, 64);
		struct Eq_n * dx_n = Mem11[ds:0x91:word16];
		struct Eq_n * ax_n = __align(si_n + 0x3F, 64) + Mem11[ds:0x7B:word16];
		byte al_n = (byte) ax_n;
		if (ax_n > dx_n)
			si_n = dx_n - Mem11[ds:0x7B:word16];
		Eq_n ax_n = fn0800_A401(al_n, ds, Mem35[ds:0x7B:word16], si_n, out bx);
		cx_n = si_n;
		byte ch_n = SLICE(si_n, byte, 8);
		dx_n = ax_n;
		if (ax_n != ~0x00)
		{
			Mem55[ds:0x91:word16] = Mem39[ds:0x7B:word16] + ax_n;
			Mem56[ds:0x8F:word16] = 0x00;
			ax_n = 0x00;
l0800_A1D1:
			cxOut = cx_n;
			dxOut = dx_n;
			bxOut = bx;
			return ax_n;
		}
		Mem65[ds:9880:word16] = si_n >>u 0x06;
		cx_n = SEQ(ch_n, 0x06);
	}
	Mem73[ds:141:word16] = wArg04;
	Mem74[ds:0x8B:word16] = wArg02;
	dx_n = wArg02;
	ax_n = 0x01;
	goto l0800_A1D1;
}

// 0800:A1D6: Register byte fn0800_A1D6(Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n wArg04, Register out word16 cxOut, Register out word16 dxOut, Register out word16 bxOut)
// Called from:
//      fn0800-9D41
//      fn0800_A080
byte fn0800_A1D6(Eq_n ds, Eq_n wArg02, Eq_n wArg04, word16 & cxOut, word16 & dxOut, word16 & bxOut)
{
	word16 cx_n;
	word16 dx_n;
	word16 bx_n;
	fn0800-8F2F(wArg02, Mem7[ds:0x89:word16], wArg04, Mem7[ds:0x87:word16], out cx_n, out dx_n, out bx_n);
	Eq_n C_n;
	C_n.u0 = <invalid>;
	word16 ax_n;
	if (!C_n)
	{
		fn0800-8F2F(wArg02, Mem7[ds:0x91:word16], wArg04, Mem7[ds:0x8F:word16], out cx_n, out dx_n, out bx_n);
		Eq_n Z_n;
		Z_n.u0 = <invalid>;
		Eq_n C_n;
		C_n.u0 = <invalid>;
		if ((Z_n | C_n) == 0x00 && fn0800_A162(ds, wArg02, wArg04, out cx_n, out dx_n, out bx_n) != 0x00)
		{
			ax_n = 0x00;
l0800_A213:
			cxOut = cx_n;
			dxOut = dx_n;
			bxOut = bx_n;
			return SLICE(ax_n, byte, 8);
		}
	}
	ax_n = ~0x00;
	goto l0800_A213;
}

// 0800:A215: Register Eq_n fn0800_A215(Register Eq_n ds, Stack uint32 dwArg02, Register out Eq_n dxOut)
// Called from:
//      fn0800-9E9E
//      fn0800-9F02
Eq_n fn0800_A215(Eq_n ds, uint32 dwArg02, union Eq_n & dxOut)
{
	Eq_n dx_n;
	byte ch_n;
	uint32 dx_ax_n = fn0800-8C69(CONVERT(Mem7[ds:141:word16], uint16, uint32), 0x04) + CONVERT(Mem7[ds:0x8B:word16], uint16, uint32) + dwArg02;
	cup16 ax_n = (word16) dx_ax_n;
	ci16 dx_n = SLICE(dx_ax_n, word16, 16);
	Eq_n dx_n;
	Eq_n ax_n;
	if (dx_n < 0x0F || dx_n <= 0x0F && ax_n <= ~0x00)
	{
		Eq_n ax_n = fn0800-8CCB(dwArg02, Mem7[ds:0x8B:word16], Mem7[ds:141:word16], out ch_n, out dx_n);
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		fn0800-8F2F(ax_n, Mem57[ds:0x89:word16], dx_n, Mem57[ds:0x87:word16], out cx_n, out dx_n, out bx_n);
		Eq_n C_n;
		C_n.u0 = <invalid>;
		if (!C_n)
		{
			word16 cx_n;
			word16 dx_n;
			word16 bx_n;
			fn0800-8F2F(ax_n, Mem57[ds:0x91:word16], dx_n, Mem57[ds:0x8F:word16], out cx_n, out dx_n, out bx_n);
			Eq_n Z_n;
			Z_n.u0 = <invalid>;
			Eq_n C_n;
			C_n.u0 = <invalid>;
			if ((Z_n | C_n) == 0x00)
			{
				Eq_n ax_n = Mem57[ds:141:word16];
				Eq_n dx_n = Mem57[ds:0x8B:word16];
				word16 cx_n;
				word16 dx_n;
				word16 bx_n;
				if (fn0800_A162(ds, ax_n, dx_n, out cx_n, out dx_n, out bx_n) != 0x00)
				{
					dx_n = ax_n;
					ax_n = dx_n;
l0800_A29F:
					dxOut = dx_n;
					return ax_n;
				}
			}
		}
	}
	dx_n.u0 = ~0x00;
	ax_n.u0 = ~0x00;
	goto l0800_A29F;
}

// 0800:A2A3: Register Eq_n fn0800_A2A3(Register Eq_n ds, Stack word16 wArg04, Register out word16 cxOut)
// Called from:
//      fn0800_B140
Eq_n fn0800_A2A3(Eq_n ds, word16 wArg04, word16 & cxOut)
{
	segptr32 ptrArg06;
	byte bArg04 = (byte) wArg04;
	msdos_unknown_n();
	Eq_n dx_n = (word16) ptrArg06;
	Eq_n ax_n = SEQ(0x44, bArg04);
	Eq_n C;
	if (!C)
	{
		if (wArg04 == 0x00)
			ax_n = dx_n;
	}
	else
		ax_n = fn0800-8D2B(ds, ax_n);
	word16 wArg0A;
	cxOut = wArg0A;
	return ax_n;
}

// 0800:A2CC: void fn0800_A2CC(Register Eq_n ds)
// Called from:
//      fn0800-9828
void fn0800_A2CC(Eq_n ds)
{
	Mem0[ds:9972:word16]();
}

// 0800:A2D0: void fn0800_A2D0(Register Eq_n ds)
// Called from:
//      fn0800-8F97
void fn0800_A2D0(Eq_n ds)
{
	Mem0[ds:0x26F6:word16]();
}

// 0800:A2D4: void fn0800_A2D4(Register Eq_n ds)
// Called from:
//      fn0800-8F97
void fn0800_A2D4(Eq_n ds)
{
	Mem0[ds:9976:word16]();
}

// 0800:A2D8: void fn0800_A2D8(Register Eq_n ds)
// Called from:
//      fn0800-8F97
void fn0800_A2D8(Eq_n ds)
{
	Mem0[ds:9978:word16]();
}

// 0800:A36D: void fn0800_A36D(Sequence (ptr32 Eq_n) ds_si, Sequence (ptr32 byte) es_di, Register word16 ax, Register word16 cx)
void fn0800_A36D(struct Eq_n * ds_si, byte * es_di, word16 ax, word16 cx)
{
	byte al_n = (byte) ax;
	if (ax != 0x00)
		*es_di = al_n;
	if (cx != 0x00)
	{
		byte al_n = ds_si->b0000;
		if (al_n != 0x22)
		{
			if (al_n == 0x5C)
				ds_si->b0001 != 0x22;
		}
	}
}

// 0800:A401: Register word16 fn0800_A401(Register byte al, Register Eq_n ds, Stack (ptr16 Eq_n) psegArg02, Stack cu16 wArg04, Register out word16 bxOut)
// Called from:
//      fn0800_A162
word16 fn0800_A401(byte al, Eq_n ds, struct Eq_n * psegArg02, cu16 wArg04, word16 & bxOut)
{
	Eq_n ax_n = SEQ(0x4A, al);
	word16 bx_n;
	word16 ax_n;
	if (!msdos_resize_memory_block(psegArg02, wArg04, out bx_n))
		ax_n = ~0x00;
	else
	{
		fn0800-8D2B(ds, ax_n);
		ax_n = bx_n;
	}
	bxOut = bx_n;
	return ax_n;
}

// 0800:A471: Register word16 fn0800_A471(Register Eq_n ds, Stack segptr32 ptrArg02, Register out word16 dxOut)
// Called from:
//      fn0800_C379
word16 fn0800_A471(Eq_n ds, segptr32 ptrArg02, word16 & dxOut)
{
	struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
	byte Eq_n::* si_n = (word16) ptrArg02;
	uint8 bl_n;
	do
	{
		bl_n = es_n->*si_n;
		++si_n;
	} while ((Mem19[ds:CONVERT(bl_n, uint8, uint16) + 0x2251:byte] & 0x01) != 0x00);
	ci16 bp_n = 0x00;
	Eq_n dx_ax_n;
	dx_ax_n.u0 = 0x00;
	Eq_n dx_ax_n;
	if (bl_n != 0x2B)
	{
		dx_ax_n.u0 = 0x00;
		if (bl_n != 0x2D)
		{
l0800_A4A2:
			Mem152 = Mem19;
			uint16 ax_n = (word16) dx_ax_n;
			Eq_n dx_ax_n = dx_ax_n;
			if (bl_n > 0x39)
			{
l0800_A4D6:
				word16 ax_n = (word16) dx_ax_n;
				word16 dx_n = SLICE(dx_ax_n, word16, 16);
				if (bp_n >= 0x01)
				{
					int32 dx_ax_n = -dx_ax_n;
					ax_n = (word16) dx_ax_n;
					dx_n = SLICE(dx_ax_n, word16, 16);
				}
				dxOut = dx_n;
				return ax_n;
			}
			uint8 bl_n = bl_n - 0x30;
			uint16 bx_n = (uint16) bl_n;
			dx_ax_n = dx_ax_n;
			if (bl_n < 0x00)
				goto l0800_A4D6;
			ui8 dh_n = SLICE(ax_n *32 0x0A, byte, 24);
			ui24 dl_ax_n = (word24) (ax_n *32 0x0A) + SEQ(dh_n, bx_n);
			uint8 dl_n = SLICE(dl_ax_n, byte, 16);
			uint16 ax_n = (word16) dl_ax_n;
			ui16 dx_n = SEQ(dh_n, dl_n);
			dx_ax_n = SEQ(dx_n, ax_n);
			if (dl_n != 0x00)
			{
				Eq_n dx_ax_n = SEQ(dx_n, ax_n);
				while (true)
				{
					uint16 ax_n = (word16) dx_ax_n;
					uint16 dx_n = SLICE(dx_ax_n, word16, 16);
					uint8 bl_n = es_n->*si_n;
					++si_n;
					dx_ax_n = dx_ax_n;
					if (bl_n > 0x39)
						break;
					uint16 bx_n = (uint16) (bl_n - 0x30);
					dx_ax_n = dx_ax_n;
					if (bl_n < 0x30)
						break;
					dx_ax_n = SEQ(dx_n * 0x0A, ax_n * 0x0A) + SEQ(SLICE(ax_n *32 0x0A, word16, 16), bx_n);
				}
				goto l0800_A4D6;
			}
			goto l0800_A49E;
		}
		bp_n = 0x01;
		dx_ax_n.u0 = 0x00;
	}
l0800_A49E:
	bl_n = es_n->*si_n;
	++si_n;
	dx_ax_n = dx_ax_n;
	goto l0800_A4A2;
}

// 0800:A4F6: void fn0800_A4F6(Register Eq_n ds, Stack Eq_n wArg06)
// Called from:
//      fn0800-37DF
//      fn0800-3C99
void fn0800_A4F6(Eq_n ds, Eq_n wArg06)
{
	word16 cx_n;
	word16 cx_n;
	if (fn0800_A53C(ds, 0x00, out cx_n) == ~0x00 || fn0800_A53C(ds, 0x01, out cx_n) == ~0x00)
		;
}

// 0800:A53C: Register Eq_n fn0800_A53C(Register Eq_n ds, Stack byte bArg06, Register out Eq_n cxOut)
// Called from:
//      fn0800_A4F6
//      fn0800_B140
Eq_n fn0800_A53C(Eq_n ds, byte bArg06, union Eq_n & cxOut)
{
	Eq_n wArg08;
	__syscall<byte>(33);
	Eq_n cx_n = wArg08;
	Eq_n ax_n = SEQ(0x43, bArg06);
	Eq_n C;
	Eq_n ax_n;
	if (!C)
	{
		cx_n = ax_n;
		ax_n = wArg08;
	}
	else
		ax_n = fn0800-8D2B(ds, ax_n);
	cxOut = cx_n;
	return ax_n;
}

// 0800:A559: void fn0800_A559(Register Eq_n al, Register Eq_n ds, Stack Eq_n wArg02)
// Called from:
//      fn0800_A614
void fn0800_A559(Eq_n al, Eq_n ds, Eq_n wArg02)
{
	if (wArg02 >=u Mem7[ds:9448:word16])
		fn0800-8D2B(ds, 0x06);
	else
	{
		(*((word32) ds + 9450))[wArg02] = 0x00;
		fn0800_A57F(al, ds, wArg02);
	}
}

// 0800:A57F: void fn0800_A57F(Register Eq_n al, Register Eq_n ds, Stack Eq_n wArg02)
// Called from:
//      fn0800_A559
//      fn0800_B140
void fn0800_A57F(Eq_n al, Eq_n ds, Eq_n wArg02)
{
	Eq_n ax_n = SEQ(0x3E, al);
	if (!msdos_close_file(wArg02))
		(*((word32) ds + 9450))[wArg02] = 0x00;
	else
		fn0800-8D2B(ds, ax_n);
}

// 0800:A59D: Register Eq_n fn0800_A59D(Register Eq_n ds, Stack Eq_n wArg02)
// Called from:
//      fn0800_AED6
Eq_n fn0800_A59D(Eq_n ds, Eq_n wArg02)
{
	word16 dx_n;
	Eq_n wLoc08_n;
	if (wArg02 >=u Mem7[ds:9448:word16])
	{
		wLoc08_n.u0 = 0x06;
		goto l0800_A60D;
	}
	Eq_n ax_n;
	if (((*((word32) ds + 9450))[wArg02] & 0x0200) != 0x00)
	{
l0800_A5BF:
		ax_n.u0 = 0x01;
		return ax_n;
	}
	Eq_n ax_n;
	ax_n.u0 = 0x4400;
	byte dl_n = (byte) dx_n;
	if (!msdos_ioctl_get_device_info(wArg02, out dx_n))
	{
		if ((dl_n & 0x80) != 0x00)
		{
l0800_A608:
			ax_n.u0 = 0x00;
			return ax_n;
		}
		int32 * dx_ax_n;
		ax_n = (word16) dx_ax_n;
		if (!msdos_set_file_position(wArg02, 0x00, 0x01, out dx_ax_n))
		{
			int32 * dx_ax_n;
			ax_n = (word16) dx_ax_n;
			cup16 dx_n = SLICE(dx_ax_n, word16, 16);
			if (!msdos_set_file_position(wArg02, 0x00, 0x02, out dx_ax_n))
			{
				int32 * dx_ax_n;
				ax_n = (word16) dx_ax_n;
				cup16 dx_n = SLICE(dx_ax_n, word16, 16);
				if (!msdos_set_file_position(wArg02, dx_ax_n, 0x00, out dx_ax_n))
				{
					if (dx_n >= dx_n && (dx_n > dx_n || ax_n >= ax_n))
						goto l0800_A5BF;
					goto l0800_A608;
				}
			}
		}
	}
	wLoc08_n = ax_n;
l0800_A60D:
	ax_n = fn0800-8D2B(ds, wLoc08_n);
	return ax_n;
}

// 0800:A614: Register Eq_n fn0800_A614(Register Eq_n ds, Stack Eq_n ptrArg02, Register out Eq_n dsOut)
// Called from:
//      fn0800-0DA9
//      fn0800-0DE8
//      fn0800-112D
//      fn0800-12E2
//      fn0800-18D9
//      fn0800-19EE
//      fn0800-2DE2
//      fn0800-37DF
//      fn0800-388C
//      fn0800-3992
//      fn0800-3BC3
//      fn0800-3C99
//      fn0800_A96D
Eq_n fn0800_A614(Eq_n ds, Eq_n ptrArg02, union Eq_n & dsOut)
{
	word16 wArg02_n = (word16) ptrArg02;
	Eq_n wArg04_n;
	wArg04_n.u3 = SLICE(ptrArg02, word16, 16);
	Eq_n cx;
	if (ptrArg02.u5->w0012 == wArg02_n)
	{
		if (ptrArg02.u5->t0006.u2 != 0x00)
		{
			if (ptrArg02.u5->t0000.u1.u2 < 0x00)
			{
				cx = wArg04_n;
				word16 dx_n;
				word16 bx_n;
				if (fn0800_A6B7(ds, ptrArg02, out dx_n, out bx_n) != 0x00)
					goto l0800_A6B2;
			}
			if ((ptrArg02.u5->t0002.u1.u2 & 0x04) != 0x00)
			{
				Eq_n v20_n;
				v20_n.u2 = ptrArg02.u5->t000A.u2;
				word16 cx_n;
				word16 dx_n;
				word16 bx_n;
				fn0800-9E75(ds, v20_n, out cx_n, out dx_n, out bx_n, out ds);
				cx = v20_n;
			}
		}
		if (ptrArg02.u5->t0004.u0 >= 0x00)
		{
			Eq_n al_n;
			al_n.u0 = ptrArg02.u5->t0004.u0;
			Eq_n ax_n;
			ax_n.u3 = (int16) al_n;
			fn0800_A559(al_n, ds, ax_n);
			cx = ax_n;
		}
		ptrArg02.u5->t0002.u1.u2 = 0x00;
		ptrArg02.u5->t0006.u2 = 0x00;
		ptrArg02.u5->t0000.u1.u2 = (uint16) 0x00;
		ptrArg02.u5->t0004.u0 = ~0x00;
		if (ptrArg02.u5->w0010 != 0x00)
		{
			char * dx_ax_n = fn0800-8E6A(ds, ptrArg02.u5->w0010, 0x00, 0x00, 0x00);
			fn0800-97F8(ds, dx_ax_n);
			ptrArg02.u5->w0010 = 0x00;
			cx.u3 = SLICE(dx_ax_n, word16, 16);
		}
	}
l0800_A6B2:
	dsOut = ds;
	return cx;
}

// 0800:A6B7: Register word16 fn0800_A6B7(Register Eq_n ds, Stack Eq_n ptrArg02, Register out Eq_n dxOut, Register out word16 bxOut)
// Called from:
//      fn0800_A614
//      fn0800_A877
//      fn0800_ACB3
//      fn0800_AE10
//      fn0800_B324
//      fn0800_B4BE
word16 fn0800_A6B7(Eq_n ds, Eq_n ptrArg02, union Eq_n & dxOut, word16 & bxOut)
{
	word16 wArg02 = (word16) ptrArg02;
	Eq_n wArg04;
	wArg04.u3 = SLICE(ptrArg02, word16, 16);
	Eq_n dx;
	word16 bx_n;
	if (ptrArg02 == 0x00)
	{
		dx = fn0800_A877(ds, out bx_n);
		goto l0800_A778;
	}
	word16 ax_n;
	if (ptrArg02.u5->w0012 != wArg02)
	{
l0800_A6D5:
		bx_n = wArg02;
		ax_n = ~0x00;
l0800_A77A:
		dxOut = dx;
		bxOut = bx_n;
		return ax_n;
	}
	bx_n = wArg02;
	if (ptrArg02.u5->t0000.u1.u2 < 0x00)
	{
		ci16 ax_n = ptrArg02.u5->t0006.u2 + (((ptrArg02.u5)->t0000).u1).u2;
		ptrArg02.u5->t0000.u1.u2 = (uint16) (ptrArg02.u5->t0000.u1.u2 - (ax_n + 0x01));
		Eq_n ax_n;
		ax_n.u2 = ptrArg02.u5->t000A.u2;
		Eq_n dx_n;
		dx_n.u2 = ptrArg02.u5->t0008.u2;
		ptrArg02.u5->t000E.u2 = (uint16) ax_n;
		ptrArg02.u5->t000C.u2 = (uint16) dx_n;
		if (fn0800_C632(ds, (int16) ptrArg02.u5->t0004.u0, SEQ(ax_n, dx_n), ax_n + 0x01, out dx, out bx_n) != ax_n + 0x01)
		{
			bx_n = wArg02;
			if ((ptrArg02.u5->t0002.u1.u2 & 0x0200) == 0x00)
			{
				ptrArg02.u5->t0002.u1.u2 = (uint16) (ptrArg02.u5->t0002.u1.u2 | 0x10);
				goto l0800_A6D5;
			}
		}
		goto l0800_A778;
	}
	if ((ptrArg02.u5->t0002.u1.u2 & 0x08) == 0x00)
	{
		dx = wArg02 + 0x05;
		if (ptrArg02.u5->t000E.u2 != wArg04 || ((ptrArg02.u5)->t000C).u2 != wArg02 + 0x05)
		{
l0800_A778:
			ax_n = 0x00;
			goto l0800_A77A;
		}
	}
	ptrArg02.u5->t0000.u1.u2 = (uint16) 0x00;
	bx_n = wArg02;
	dx = wArg02 + 0x05;
	if (ptrArg02.u5->t000E.u2 == wArg04 && ((ptrArg02.u5)->t000C).u2 == wArg02 + 0x05)
	{
		dx.u2 = ptrArg02.u5->t0008.u2;
		ptrArg02.u5->t000E.u2 = ptrArg02.u5->t000A.u2;
		ptrArg02.u5->t000C.u2 = (uint16) dx;
	}
	goto l0800_A778;
}

// 0800:A77D: Register word16 fn0800_A77D(Register Eq_n ds, Stack (ptr32 byte) dwArg02, Stack ci16 wArg06, Stack Eq_n ptrArg08, Register out word16 dxOut)
// Called from:
//      fn0800-2DE2
word16 fn0800_A77D(Eq_n ds, byte * dwArg02, ci16 wArg06, Eq_n ptrArg08, word16 & dxOut)
{
	word16 wArg04 = SLICE(dwArg02, word16, 16);
	word16 wArg02 = (word16) dwArg02;
	ci16 di_n = wArg06;
	Eq_n cx_n;
	cx_n.u0 = 0x00;
	byte * ptrLoc06_n = dwArg02;
	word16 wLoc06_n;
	word16 wLoc04_n;
	while (true)
	{
		wLoc06_n = (word16) ptrLoc06_n;
		wLoc04_n = SLICE(ptrLoc06_n, word16, 16);
		if (cx_n == 0x0A)
			break;
		--di_n;
		if (di_n <= 0x00)
			break;
		Eq_n v20_n = ptrArg08.u5->t0000.u1.u2 - 0x01;
		ptrArg08.u5->t0000.u1.u2 = (uint16) v20_n;
		Eq_n ax_n;
		if (v20_n >= 0x00)
		{
			Eq_n ax_n;
			ax_n.u2 = ptrArg08.u5->t000E.u2;
			union Eq_n Eq_n::* si_n = (union Eq_n Eq_n::*) ptrArg08.u5->t000C.u2;
			ptrArg08.u5->t000C.u2 = (uint16) (ptrArg08.u5->t000C.u2 + 0x01);
			ax_n.u2 = (uint16) (ax_n->*si_n).u0;
		}
		else
		{
			byte ch_n;
			ax_n = fn0800_AEC2(ds, ptrArg08, out ch_n);
		}
		cx_n = ax_n;
		byte cl_n = (byte) ax_n;
		if (ax_n == ~0x00)
			break;
		*ptrLoc06_n = cl_n;
		ptrLoc06_n = SEQ(wLoc04_n, wLoc06_n + 0x01);
	}
	word16 dx_n;
	word16 ax_n;
	if (cx_n == ~0x00 && (wLoc04_n == wArg04 && wLoc06_n == wArg02))
	{
		dx_n = 0x00;
		ax_n = 0x00;
	}
	else
	{
		*ptrLoc06_n = 0x00;
		if ((ptrArg08.u5->t0002.u1.u2 & 0x10) != 0x00)
		{
			dx_n = 0x00;
			ax_n = 0x00;
		}
		else
		{
			dx_n = wArg04;
			ax_n = wArg02;
		}
	}
	dxOut = dx_n;
	return ax_n;
}

// 0800:A817: Register Eq_n fn0800_A817(Register byte al, Register Eq_n ds, Stack Eq_n ptrArg02, Stack (ptr32 char) ptrArg06, Stack cui16 wArg0A, Register out uint16 cxOut, Register out word16 dxOut)
// Called from:
//      fn0800-33CD
//      fn0800-363D
Eq_n fn0800_A817(byte al, Eq_n ds, Eq_n ptrArg02, char * ptrArg06, cui16 wArg0A, uint16 & cxOut, word16 & dxOut)
{
	ui32 SCZDOP;
	char * es_bx_n = msdos_get_disk_transfer_area_address();
	msdos_set_DTA(ptrArg06);
	uint16 v16_n = (word16) (msdos_find_first_file(wArg0A, ptrArg02) | SCZDOP);
	msdos_set_DTA(es_bx_n);
	word16 bx_n = (word16) es_bx_n;
	Eq_n ax_n = SEQ(0x4E, al);
	Eq_n ax_n;
	if (!(SEQ(SLICE(SCZDOP, word16, 16), v16_n) & 0x02))
		ax_n.u0 = 0x00;
	else
		ax_n = fn0800-8D2B(ds, ax_n);
	cxOut = v16_n;
	dxOut = bx_n;
	return ax_n;
}

// 0800:A84A: Register Eq_n fn0800_A84A(Register byte al, Register Eq_n ds, Stack (ptr32 char) ptrArg02, Register out uint16 cxOut, Register out word16 dxOut)
// Called from:
//      fn0800-3479
Eq_n fn0800_A84A(byte al, Eq_n ds, char * ptrArg02, uint16 & cxOut, word16 & dxOut)
{
	ui32 SCZDOP;
	char * es_bx_n = msdos_get_disk_transfer_area_address();
	msdos_set_DTA(ptrArg02);
	uint16 v15_n = (word16) (msdos_find_next_file() | SCZDOP);
	msdos_set_DTA(es_bx_n);
	word16 bx_n = (word16) es_bx_n;
	Eq_n ax_n = SEQ(0x4F, al);
	Eq_n ax_n;
	if (!(SEQ(SLICE(SCZDOP, word16, 16), v15_n) & 0x02))
		ax_n.u0 = 0x00;
	else
		ax_n = fn0800-8D2B(ds, ax_n);
	cxOut = v15_n;
	dxOut = bx_n;
	return ax_n;
}

// 0800:A877: Register Eq_n fn0800_A877(Register Eq_n ds, Register out Eq_n bxOut)
// Called from:
//      fn0800_A6B7
Eq_n fn0800_A877(Eq_n ds, union Eq_n & bxOut)
{
	Eq_n si_n = Mem15[ds:9448:word16];
	struct Eq_n * ptrLoc06_n = SEQ(ds, 0x2358);
	Eq_n bx;
	while (true)
	{
		word16 wLoc04_n = SLICE(ptrLoc06_n, word16, 16);
		word16 wLoc06_n = (word16) ptrLoc06_n;
		--si_n;
		if (si_n == 0x00)
			break;
		bx = (word16) ptrLoc06_n;
		if ((ptrLoc06_n->w0002 & 0x03) != 0x00)
		{
			word16 dx_n;
			fn0800_A6B7(ds, bx, out dx_n, out bx);
		}
		ptrLoc06_n = SEQ(wLoc04_n, wLoc06_n + 0x14);
	}
	bxOut = bx;
	return <invalid>;
}

// 0800:A8B7: Register cui16 fn0800_A8B7(Register Eq_n ds, Stack (ptr32 word16) ptrArg02, Stack (ptr32 cui16) ptrArg06, Stack Eq_n ptrArg0A, Register out Eq_n clOut)
// Called from:
//      fn0800_A96D
cui16 fn0800_A8B7(Eq_n ds, word16 * ptrArg02, cui16 * ptrArg06, Eq_n ptrArg0A, union Eq_n & clOut)
{
	word16 wArg0A_n = (word16) ptrArg0A;
	word16 wArg0C_n = SLICE(ptrArg0A, word16, 16);
	word16 di_n = 0x00;
	Eq_n cl_n;
	cl_n.u3 = *ptrArg0A.u3;
	union Eq_n * ptrArg0A_n = SEQ(wArg0C_n, wArg0A_n + 0x01);
	cui16 dx_n;
	cui16 si_n;
	cui16 ax_n;
	if (cl_n == 114)
	{
		dx_n = 0x01;
		si_n = 0x01;
	}
	else
	{
		if (cl_n == 0x77)
			dx_n = 770;
		else
		{
			if (cl_n != 0x61)
			{
				ax_n = 0x00;
l0800_A967:
				clOut = cl_n;
				return ax_n;
			}
			dx_n = 0x0902;
		}
		di_n = 0x80;
		si_n = 0x02;
	}
	cl_n.u0 = ptrArg0A_n->u0;
	union Eq_n * ptrArg0A_n = SEQ(wArg0C_n, wArg0A_n + 0x02);
	if (cl_n == 0x2B || ptrArg0A_n->u0 == 0x2B && (cl_n == 116 || cl_n == 0x62))
	{
		if (cl_n == 0x2B)
			cl_n.u0 = ptrArg0A_n->u0;
		dx_n = dx_n & ~0x03 | 0x04;
		di_n = 0x0180;
		si_n = 0x03;
	}
	cui16 dx_n;
	if (cl_n == 116)
	{
		dx_n = dx_n | 0x4000;
		goto l0800_A953;
	}
	if (cl_n == 0x62)
		dx_n = dx_n | 0x8000;
	else
	{
		dx_n = dx_n | Mem50[ds:0x2512:word16] & 0xC000;
		if ((dx_n & 0x8000) == 0x00)
			goto l0800_A953;
	}
	si_n |= 0x40;
l0800_A953:
	Mem123[ds:9044:word16] = 51125;
	*ptrArg06 = dx_n;
	*ptrArg02 = di_n;
	ax_n = si_n;
	goto l0800_A967;
}

// 0800:A96D: Register word16 fn0800_A96D(Register Eq_n ds, Stack cui16 wArg02, Stack Eq_n dwArg04, Stack Eq_n dwArg08, Stack Eq_n ptrArg0C, Register out word16 cxOut, Register out word16 dxOut, Register out Eq_n dsOut)
// Called from:
//      fn0800_AA7E
word16 fn0800_A96D(Eq_n ds, cui16 wArg02, Eq_n dwArg04, Eq_n dwArg08, Eq_n ptrArg0C, word16 & cxOut, word16 & dxOut, union Eq_n & dsOut)
{
	cui16 wLoc06;
	cui16 wLoc04;
	byte ch;
	byte cl_n;
	<unknown> Eq_n::* fp;
	word16 wArg0E_n = SLICE(ptrArg0C, word16, 16);
	Eq_n ax_n = fn0800_A8B7(ds, fp - 6, fp - 4, dwArg04, out cl_n);
	ptrArg0C.u5->t0002.u1.u2 = (uint16) ax_n;
	word16 cx_n = SEQ(ch, cl_n);
	if (ax_n == 0x00)
	{
l0800_A9B9:
		ptrArg0C.u5->t0004.u0 = ~0x00;
		ptrArg0C.u5->t0002.u1.u2 = (uint16) 0x00;
		goto l0800_A9C7;
	}
	else
	{
		if (ptrArg0C.u5->t0004.u0 < 0x00)
		{
			Eq_n al_n = fn0800_B140(ds, dwArg08, wLoc04 | wArg02, wLoc06, out cx_n);
			ptrArg0C.u5->t0004.u0 = (int8) al_n;
			if (al_n < 0x00)
				goto l0800_A9B9;
		}
		if (fn0800-8D76((int16) ptrArg0C.u5->t0004.u0) != 0x00)
			ptrArg0C.u5->t0002.u1.u2 = (uint16) (ptrArg0C.u5->t0002.u1.u2 | 0x0200);
		ci16 ax_n;
		if ((ptrArg0C.u5->t0002.u1.u2 & 0x0200) != 0x00)
			ax_n = 0x01;
		else
			ax_n = 0x00;
		word16 wArg0E_n = SLICE(ptrArg0C, word16, 16);
		word16 wArg0C_n = (word16) ptrArg0C;
		word16 dx_n;
		word16 ax_n;
		if (fn0800_BA89(ds, ptrArg0C, 0x00, 0x00, ax_n, 0x0200, out cx_n, out ds) == 0x00)
		{
			ptrArg0C.u5->w0010 = 0x00;
			dx_n = wArg0E_n;
			ax_n = wArg0C_n;
			goto l0800_AA2E;
		}
		fn0800_A614(ds, ptrArg0C, out ds);
		cx_n = wArg0E_n;
l0800_A9C7:
		dx_n = 0x00;
		ax_n = 0x00;
l0800_AA2E:
		cxOut = cx_n;
		dxOut = dx_n;
		dsOut = ds;
		return ax_n;
	}
}

// 0800:AA34: Sequence word32 fn0800_AA34(Register Eq_n ds)
// Called from:
//      fn0800_AA7E
word32 fn0800_AA34(Eq_n ds)
{
	struct Eq_n * ptrLoc06_n = SEQ(ds, 0x2358);
	Eq_n wLoc06_n;
	do
	{
		wLoc06_n = (word16) ptrLoc06_n;
		word16 wLoc04_n = SLICE(ptrLoc06_n, word16, 16);
		if (ptrLoc06_n->b0004 < 0x00)
			break;
		ptrLoc06_n = SEQ(wLoc04_n, (word16) wLoc06_n.u1 + 20);
	} while (wLoc06_n <u Mem27[ds:9448:word16] *s 0x14 + 0x2358);
	word16 wLoc04_n = SLICE(ptrLoc06_n, word16, 16);
	word16 wLoc06_n = (word16) ptrLoc06_n;
	word16 dx_n;
	word16 ax_n;
	if (ptrLoc06_n->b0004 >= 0x00)
	{
		dx_n = 0x00;
		ax_n = 0x00;
	}
	else
	{
		dx_n = wLoc04_n;
		ax_n = wLoc06_n;
	}
	return SEQ(dx_n, ax_n);
}

// 0800:AA7E: Sequence word32 fn0800_AA7E(Register Eq_n ds, Stack Eq_n dwArg02, Stack Eq_n dwArg06, Register out word16 cxOut, Register out Eq_n dsOut)
// Called from:
//      fn0800-12E2
//      fn0800-18D9
//      fn0800-19EE
//      fn0800-37DF
//      fn0800-3992
//      fn0800-4234
word32 fn0800_AA7E(Eq_n ds, Eq_n dwArg02, Eq_n dwArg06, word16 & cxOut, union Eq_n & dsOut)
{
	Eq_n dx_ax_n = fn0800_AA34(ds);
	word16 dx_n;
	word16 ax_n;
	word16 cx;
	if (dx_ax_n == 0x00)
	{
		dx_n = 0x00;
		ax_n = 0x00;
	}
	else
		ax_n = fn0800_A96D(ds, 0x00, dwArg06, dwArg02, dx_ax_n, out cx, out dx_n, out ds);
	cxOut = cx;
	dsOut = ds;
	return SEQ(dx_n, ax_n);
}

// 0800:AAB3: Register Eq_n fn0800_AAB3(Register Eq_n dx, Register Eq_n ds, Stack Eq_n ptrArg02, Stack Eq_n wArg06, Stack Eq_n ptrArg08, Register out byte chOut)
// Called from:
//      fn0800_ABA3
Eq_n fn0800_AAB3(Eq_n dx, Eq_n ds, Eq_n ptrArg02, Eq_n wArg06, Eq_n ptrArg08, byte & chOut)
{
	Eq_n ptrArg08_n = ptrArg08;
	Eq_n di_n;
	Eq_n ax_n;
	do
	{
		word16 wArg08_n = (word16) ptrArg08_n;
		word16 wArg0A_n = SLICE(ptrArg08_n, word16, 16);
		if (wArg06 == 0x00)
			goto l0800_AB9A;
		Eq_n v11_n;
		v11_n.u3 = &wArg06.u5->b0001;
		wArg06 = v11_n;
		Eq_n ax_n;
		if (ptrArg02.u5->t0006.u2 > v11_n)
			ax_n = v11_n;
		else
			ax_n.u2 = ptrArg02.u5->t0006.u2;
		Eq_n di_n = ax_n;
		if ((ptrArg02.u5->t0002.u1.u2 & 0x40) == 0x00 || (((ptrArg02.u5)->t0006).u2 == 0x00 || (((ptrArg02.u5)->t0006).u2 >= v11_n || (((ptrArg02.u5)->t0000).u1).u2 != 0x00)))
		{
			while (true)
			{
				Eq_n v22_n = wArg06 - 0x01;
				word16 wArg08_n = (word16) ptrArg08_n;
				word16 wArg0A_n = SLICE(ptrArg08_n, word16, 16);
				wArg06 = v22_n;
				if (v22_n == 0x00)
					break;
				--di_n;
				if (di_n == 0x00)
					break;
				Eq_n v23_n = ptrArg02.u5->t0000.u1.u2 - 0x01;
				ptrArg02.u5->t0000.u1.u2 = (uint16) v23_n;
				Eq_n ax_n;
				if (v23_n >= 0x00)
				{
					Eq_n ax_n;
					ax_n.u2 = ptrArg02.u5->t000E.u2;
					Eq_n si_n;
					si_n.u2 = ptrArg02.u5->t000C.u2;
					ptrArg02.u5->t000C.u2 = (uint16) (ptrArg02.u5->t000C.u2 + 0x01);
					ax_n.u2 = (uint16) (ax_n->*si_n.u3);
				}
				else
				{
					byte ch_n;
					ax_n = fn0800_AEC2(ds, ptrArg02, out ch_n);
				}
				dx = ax_n;
				Eq_n dl_n = (byte) ax_n;
				if (ax_n == ~0x00)
					break;
				*ptrArg08_n.u3 = (char) dl_n;
				ptrArg08_n = SEQ(wArg0A_n, wArg08_n + 0x01);
			}
			if (dx != ~0x00)
				continue;
			goto l0800_AB3D;
		}
		di_n.u0 = 0x00;
		for (wArg06 = v11_n - 0x01; ptrArg02.u5->t0006.u2 <= wArg06; wArg06 -= ptrArg02.u5->t0006.u2)
			di_n.u3 += ptrArg02.u5->t0006.u2;
		byte ch_n;
		ax_n = fn0800-8F50(ds, (int16) ptrArg02.u5->t0004.u0, ptrArg08_n, di_n, out ch_n);
		dx = ax_n;
		ptrArg08_n = SEQ(wArg0A_n, ax_n.u3 + wArg08_n);
	} while (ax_n == di_n);
	wArg06.u3 += di_n - ax_n;
l0800_AB3D:
	ptrArg02.u5->t0002.u1.u2 = (uint16) (ptrArg02.u5->t0002.u1.u2 | 0x20);
l0800_AB9A:
	chOut = <invalid>;
	return wArg06;
}

// 0800:ABA3: Register uint16 fn0800_ABA3(Register Eq_n ds, Stack Eq_n dwArg02, Stack Eq_n wArg06, Stack Eq_n wArg08, Stack Eq_n dwArg0A, Register out byte chOut)
// Called from:
//      fn0800-4110
uint16 fn0800_ABA3(Eq_n ds, Eq_n dwArg02, Eq_n wArg06, Eq_n wArg08, Eq_n dwArg0A, byte & chOut)
{
	byte ch_n;
	uint16 ax_n;
	if (wArg06 == 0x00)
		ax_n = 0x00;
	else
	{
		ui32 dx_ax_n = fn0800-8F18(wArg08, 0x00, 0x00, wArg06, out ch_n);
		Eq_n ax_n = (word16) dx_ax_n;
		Eq_n dx_n;
		dx_n.u3 = SLICE(dx_ax_n, word16, 16);
		if (dx_n <= 0x01 && (dx_n < 0x01 || true))
		{
			byte ch_n;
			ax_n = (uint32) (ax_n - fn0800_AAB3(dx_n, ds, dwArg0A, ax_n, dwArg02, out ch_n)) /u wArg06;
		}
		else
		{
			word16 si_n = (word16) &wArg08.u5->b0001;
			while (true)
			{
				Eq_n wArg02_n = (word16) dwArg02;
				Eq_n wArg04_n;
				wArg04_n.u3 = SLICE(dwArg02, word16, 16);
				--si_n;
				byte ch_n;
				if (si_n == 0x00 || fn0800_AAB3(dx_n, ds, dwArg0A, wArg06, dwArg02, out ch_n) != 0x00)
					break;
				Eq_n dx_n;
				byte ch_n;
				dwArg02 = SEQ(dx_n, fn0800-8CCB((uint32) wArg06, wArg02_n, wArg04_n, out ch_n, out dx_n));
				dx_n = dx_n;
			}
			ax_n = wArg08 - si_n;
		}
	}
	chOut = <invalid>;
	return ax_n;
}

// 0800:AC31: Register Eq_n fn0800_AC31(Stack Eq_n ptrArg02)
// Called from:
//      fn0800_ACB3
//      fn0800_AD2F
Eq_n fn0800_AC31(Eq_n ptrArg02)
{
	byte * ptrLoc06_n;
	Eq_n cx_n;
	Eq_n si_n;
	if (ptrArg02.u5->t0000.u1.u2 < 0x00)
	{
		word16 cx_n = ptrArg02.u5->t0006.u2 + (((ptrArg02.u5)->t0000).u1).u2;
		cx_n = cx_n + 0x01;
		si_n = cx_n + 0x01;
	}
	else
	{
		Eq_n ax_n;
		ax_n.u2 = ptrArg02.u5->t0000.u1.u2;
		cx_n = ax_n;
		si_n = ax_n;
	}
	if ((ptrArg02.u5->t0002.u1.u2 & 0x40) == 0x00)
	{
		Eq_n dx_n;
		dx_n.u2 = ptrArg02.u5->t000C.u2;
		Eq_n ax_n;
		ax_n.u2 = ptrArg02.u5->t000E.u2;
		Eq_n wLoc06_n = dx_n;
		byte * ptrLoc06_n = SEQ(ax_n, dx_n);
		if (ptrArg02.u5->t0000.u1.u2 < 0x00)
		{
			while (true)
			{
				--cx_n;
				if (cx_n == 0x00)
					break;
				Eq_n v22_n = wLoc06_n - 0x01;
				wLoc06_n = v22_n;
				if (*SEQ(ax_n, v22_n) == 0x0A)
					si_n.u3 = &si_n.u5->b0001;
			}
		}
		else
		{
			while (true)
			{
				word16 wLoc06_n = (word16) ptrLoc06_n;
				word16 wLoc04_n = SLICE(ptrLoc06_n, word16, 16);
				--cx_n;
				if (cx_n == 0x00)
					break;
				ptrLoc06_n = SEQ(wLoc04_n, wLoc06_n + 0x01);
				ptrLoc06_n = ptrLoc06_n;
				if (*ptrLoc06_n == 0x0A)
					si_n.u3 = &si_n.u5->b0001;
			}
		}
	}
	return si_n;
}

// 0800:ACB3: Register word16 fn0800_ACB3(Register Eq_n ds, Stack Eq_n ptrArg02, Stack Eq_n dwArg06, Stack Eq_n wArg0A, Register out word16 cxOut)
// Called from:
//      fn0800-12E2
//      fn0800-19EE
//      fn0800-1CF6
//      fn0800-1E5E
//      fn0800-24FE
//      fn0800-2D0A
//      fn0800-3BC3
//      fn0800-3C99
//      fn0800-3E9A
//      fn0800-3F0A
//      fn0800-3F58
//      fn0800-4194
//      fn0800-46FE
//      fn0800-4BB1
//      fn0800-4C55
//      fn0800-4F2C
//      fn0800-51A9
//      fn0800-5374
//      fn0800-5B15
//      fn0800-5DCE
//      fn0800-5E64
//      fn0800-67BF
//      fn0800-6F20
//      fn0800-73AC
//      fn0800-741D
//      fn0800-75EA
//      fn0800-7A02
//      fn0800-7C78
//      fn0800-7FDC
//      fn0800_BA67
//      fn0800_BA89
word16 fn0800_ACB3(Eq_n ds, Eq_n ptrArg02, Eq_n dwArg06, Eq_n wArg0A, word16 & cxOut)
{
	word16 dx_n;
	word16 wArg04 = SLICE(ptrArg02, word16, 16);
	word16 cx_n = wArg04;
	word16 dx_n;
	word16 bx_n;
	word16 ax_n;
	if (fn0800_A6B7(ds, ptrArg02, out dx_n, out bx_n) != 0x00)
		ax_n = ~0x00;
	else
	{
		if (wArg0A == 0x01 && (((ptrArg02.u5)->t0000).u1).u2 > 0x00)
			dwArg06 -= (uint32) fn0800_AC31(ptrArg02);
		ptrArg02.u5->t0002.u1.u2 &= ~0x01A0;
		ptrArg02.u5->t0000.u1.u2 = (uint16) 0x00;
		union Eq_n Eq_n::* dx_n = (union Eq_n Eq_n::*) ptrArg02.u5->t0008.u2;
		ptrArg02.u5->t000E.u2 = ptrArg02.u5->t000A.u2;
		ptrArg02.u5->t000C.u2 = (uint16) dx_n;
		uint16 ax_n = fn0800-8E29(ds, (int16) ptrArg02.u5->t0004.u0, dwArg06, (byte) wArg0A, out cx_n, out dx_n);
		if (dx_n == ~0x00 && ax_n == ~0x00)
			ax_n = ~0x00;
		else
			ax_n = 0x00;
	}
	cxOut = cx_n;
	return ax_n;
}

// 0800:AD2F: Sequence int32 fn0800_AD2F(Register Eq_n ds, Stack Eq_n ptrArg02)
// Called from:
//      fn0800-12E2
//      fn0800-2D0A
//      fn0800-4194
//      fn0800-46FE
//      fn0800-4C55
//      fn0800-4F2C
//      fn0800-51A9
//      fn0800-5374
//      fn0800-5B15
//      fn0800-5E64
//      fn0800-67BF
//      fn0800-6AD4
//      fn0800-6F20
//      fn0800-741D
//      fn0800-75EA
//      fn0800-7A02
//      fn0800-7C78
int32 fn0800_AD2F(Eq_n ds, Eq_n ptrArg02)
{
	int32 dx_ax_n = fn0800-97B6(ds, (int16) ptrArg02.u5->t0004.u0);
	int16 dx_n = SLICE(dx_ax_n, word16, 16);
	uint16 ax_n = (word16) dx_ax_n;
	int16 wLoc04_n = dx_n;
	uint16 wLoc06_n = ax_n;
	if (dx_n != ~0x00 || ax_n != ~0x00)
	{
		if (ptrArg02.u5->t0000.u1.u2 < 0x00)
		{
			uint32 v20_v18_n = dx_ax_n + (uint32) fn0800_AC31(ptrArg02);
			wLoc06_n = (word16) v20_v18_n;
			wLoc04_n = SLICE(v20_v18_n, word16, 16);
		}
		else
		{
			int32 v24_v23_n = dx_ax_n - (uint32) fn0800_AC31(ptrArg02);
			wLoc06_n = (word16) v24_v23_n;
			wLoc04_n = SLICE(v24_v23_n, word16, 16);
		}
	}
	return SEQ(wLoc04_n, wLoc06_n);
}

// 0800:AD85: Register Eq_n fn0800_AD85(Register Eq_n ds, Stack Eq_n dwArg02, Stack Eq_n wArg06, Stack Eq_n wArg08, Stack Eq_n dwArg0A)
// Called from:
//      fn0800-4152
Eq_n fn0800_AD85(Eq_n ds, Eq_n dwArg02, Eq_n wArg06, Eq_n wArg08, Eq_n dwArg0A)
{
	byte ch_n;
	Eq_n ax_n;
	if (wArg06 != 0x00)
	{
		ui32 dx_ax_n = fn0800-8F18(wArg08, 0x00, 0x00, wArg06, out ch_n);
		Eq_n ax_n = (word16) dx_ax_n;
		cup16 dx_n = SLICE(dx_ax_n, word16, 16);
		if (dx_n <= 0x01 && (dx_n < 0x01 || true))
		{
			ax_n = (uint32) fn0800_B4BE(ds, dwArg0A, ax_n, dwArg02) /u wArg06;
			return ax_n;
		}
		Eq_n si_n;
		si_n.u0 = 0x00;
		if (wArg08 > 0x00)
		{
			do
			{
				Eq_n wArg02_n = (word16) dwArg02;
				Eq_n wArg04_n;
				wArg04_n.u3 = SLICE(dwArg02, word16, 16);
				Eq_n ax_n = fn0800_B4BE(ds, dwArg0A, wArg06, dwArg02);
				if (false || ax_n != wArg06)
				{
					ax_n = si_n;
					return ax_n;
				}
				si_n.u3 = &si_n.u5->b0001;
				word16 dx_n;
				byte ch_n;
				dwArg02 = SEQ(dx_n, fn0800-8CCB((uint32) wArg06, wArg02_n, wArg04_n, out ch_n, out dx_n));
			} while (si_n < wArg08);
		}
	}
	ax_n = wArg08;
	return ax_n;
}

// 0800:AE10: void fn0800_AE10(Register Eq_n ds)
// Called from:
//      fn0800_AE4C
//      fn0800_AED6
void fn0800_AE10(Eq_n ds)
{
	word16 si_n = 0x14;
	Eq_n ptrLoc06_n = SEQ(ds, 0x2358);
	while (true)
	{
		word16 wLoc04_n = SLICE(ptrLoc06_n, word16, 16);
		word16 wLoc06_n = (word16) ptrLoc06_n;
		--si_n;
		if (si_n == 0x00)
			break;
		if ((ptrLoc06_n.u5->t0002.u1.u2 & 0x0300) == 0x0300)
		{
			word16 dx_n;
			word16 bx_n;
			fn0800_A6B7(ds, ptrLoc06_n, out dx_n, out bx_n);
		}
		ptrLoc06_n = SEQ(wLoc04_n, wLoc06_n + 0x14);
	}
}

// 0800:AE4C: Register word16 fn0800_AE4C(Register Eq_n ds, Stack Eq_n ptrArg02)
// Called from:
//      fn0800_AED6
word16 fn0800_AE4C(Eq_n ds, Eq_n ptrArg02)
{
	if ((ptrArg02.u5->t0002.u1.u2 & 0x0200) != 0x00)
		fn0800_AE10(ds);
	Eq_n v13_n;
	v13_n.u2 = ptrArg02.u5->t0006.u2;
	Eq_n ax_n;
	ax_n.u2 = ptrArg02.u5->t000A.u2;
	Eq_n dx_n;
	dx_n.u2 = ptrArg02.u5->t0008.u2;
	ptrArg02.u5->t000E.u2 = (uint16) ax_n;
	ptrArg02.u5->t000C.u2 = (uint16) dx_n;
	Eq_n ax_n = fn0800_B97F(ds, (int16) ptrArg02.u5->t0004.u0, SEQ(ax_n, dx_n), v13_n);
	ptrArg02.u5->t0000.u1.u2 = (uint16) ax_n;
	word16 ax_n;
	if (ax_n > 0x00)
	{
		ptrArg02.u5->t0002.u1.u2 = (uint16) (ptrArg02.u5->t0002.u1.u2 & ~0x20);
		ax_n = 0x00;
	}
	else
	{
		if (ptrArg02.u5->t0000.u1.u2 == 0x00)
			ptrArg02.u5->t0002.u1.u2 = (uint16) (ptrArg02.u5->t0002.u1.u2 & 65151 | 0x20);
		else
		{
			ptrArg02.u5->t0000.u1.u2 = (uint16) 0x00;
			ptrArg02.u5->t0002.u1.u2 = (uint16) (ptrArg02.u5->t0002.u1.u2 | 0x10);
		}
		ax_n = ~0x00;
	}
	return ax_n;
}

// 0800:AEC2: Register word16 fn0800_AEC2(Register Eq_n ds, Stack Eq_n ptrArg02, Register out byte chOut)
// Called from:
//      fn0800-3DCF
//      fn0800-3E9A
//      fn0800_A77D
//      fn0800_AAB3
word16 fn0800_AEC2(Eq_n ds, Eq_n ptrArg02, byte & chOut)
{
	ptrArg02.u5->t0000.u1.u2 = (uint16) (ptrArg02.u5->t0000.u1.u2 + 0x01);
	word16 ax_n = fn0800_AED6(ds, ptrArg02);
	chOut = <invalid>;
	return ax_n;
}

// 0800:AED6: Register uint16 fn0800_AED6(Register Eq_n ds, Stack Eq_n ptrArg02)
// Called from:
//      fn0800_AEC2
uint16 fn0800_AED6(Eq_n ds, Eq_n ptrArg02)
{
	uint16 ax_n;
	if (ptrArg02 == 0x00)
	{
l0800_AEE2:
		ax_n = ~0x00;
		return ax_n;
	}
	uint8 al_n;
	if (ptrArg02.u5->t0000.u1.u2 <= 0x00)
	{
		if (ptrArg02.u5->t0000.u1.u2 < 0x00 || (((((ptrArg02.u5)->t0002).u1).u2 & 0x0110) != 0x00 || ((((ptrArg02.u5)->t0002).u1).u2 & 0x01) == 0x00))
		{
l0800_AF7F:
			ptrArg02.u5->t0002.u1.u2 = (uint16) (ptrArg02.u5->t0002.u1.u2 | 0x10);
			goto l0800_AEE2;
		}
		ptrArg02.u5->t0002.u1.u2 = (uint16) (ptrArg02.u5->t0002.u1.u2 | 0x80);
		if (ptrArg02.u5->t0006.u2 == 0x00)
		{
			do
			{
				if ((ptrArg02.u5->t0002.u1.u2 & 0x0200) != 0x00)
					fn0800_AE10(ds);
				if (fn0800_B97F(ds, (int16) ptrArg02.u5->t0004.u0, SEQ(ds, 0x4EE4), 0x01) == 0x00)
				{
					if (fn0800_A59D(ds, (int16) ptrArg02.u5->t0004.u0) != 0x01)
						goto l0800_AF7F;
					ptrArg02.u5->t0002.u1.u2 = (uint16) (ptrArg02.u5->t0002.u1.u2 & 65151 | 0x20);
					goto l0800_AEE2;
				}
			} while (Mem83[ds:0x4EE4:byte] == 0x0D && ((((ptrArg02.u5)->t0002).u1).u2 & 0x40) == 0x00);
			ptrArg02.u5->t0002.u1.u2 = (uint16) (ptrArg02.u5->t0002.u1.u2 & ~0x20);
			al_n = Mem117[ds:0x4EE4:byte];
l0800_AFBB:
			ax_n = (uint16) al_n;
			return ax_n;
		}
		if (fn0800_AE4C(ds, ptrArg02) != 0x00)
			goto l0800_AEE2;
	}
	ptrArg02.u5->t0000.u1.u2 = (uint16) (ptrArg02.u5->t0000.u1.u2 - 0x01);
	Eq_n ax_n;
	ax_n.u2 = ptrArg02.u5->t000E.u2;
	Eq_n si_n;
	si_n.u2 = ptrArg02.u5->t000C.u2;
	ptrArg02.u5->t000C.u2 = (uint16) (ptrArg02.u5->t000C.u2 + 0x01);
	al_n = (uint8) (ax_n->*si_n.u3);
	goto l0800_AFBB;
}

// 0800:AFCB: Sequence word32 fn0800_AFCB(Register Eq_n ds, Stack Eq_n ptrArg02)
// Called from:
//      fn0800_C379
word32 fn0800_AFCB(Eq_n ds, Eq_n ptrArg02)
{
	struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
	byte Eq_n::* di_n = (word16) ptrArg02;
	int16 ax_n;
	struct Eq_n * dx_n;
	if (ptrArg02 != 0x00)
	{
		byte ah_n = *ptrArg02.u1;
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			byte Eq_n::* di_n;
			di_n = di_n + 1;
			--cx_n;
			di_n = di_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		Eq_n cx_n = ~cx_n;
		if (cx_n != 0x01)
		{
			Eq_n es_di_n = Mem15[ds:9898:segptr32];
			union Eq_n Eq_n::* di_n = (word16) es_di_n;
			union Eq_n Eq_n::* wLoc06_n = di_n;
			if (es_di_n != 0x00)
			{
				while (true)
				{
					Eq_n es_di_n;
					es_di_n.u1 = (ds->*di_n).u1;
					struct Eq_n * es_n = SLICE(es_di_n, selector, 16);
					int16 di_n = (word16) es_di_n;
					if (es_di_n == 0x00)
						break;
					byte al_n = *es_di_n.u1;
					if (al_n == 0x00)
						break;
					if (ah_n == al_n && es_n->*((char *) (cx_n - 0x01) + di_n) == 0x3D)
					{
						Eq_n cmpResult_n = memcmp(ptrArg02, es_di_n, (uint32) (cx_n - 0x01));
						int16 di_n = __find_first_difference__(ptrArg02, es_di_n) + di_n;
						if (cmpResult_n == 0x00)
						{
							ax_n = di_n + 0x01;
							dx_n = es_n;
							return ax_n;
						}
					}
					union Eq_n Eq_n::* v28_n = (union Eq_n Eq_n::*) ((char *) wLoc06_n + 4);
					wLoc06_n = v28_n;
					di_n = v28_n;
				}
			}
		}
	}
	dx_n = 0x00;
	ax_n = 0x00;
	return ax_n;
}

// 0800:B03B: void fn0800_B03B(Stack Eq_n ptrArg02, Stack Eq_n ptrArg06, Stack Eq_n wArg0A)
// Called from:
//      fn0800-9CE6
//      fn0800_B4BE
void fn0800_B03B(Eq_n ptrArg02, Eq_n ptrArg06, Eq_n wArg0A)
{
	Eq_n size_n = (wArg0A >> 0x01) *32 0x02;
	memcpy(ptrArg02, ptrArg06, size_n);
	struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
	struct Eq_n * ds_n = SLICE(ptrArg06, selector, 16);
	byte Eq_n::* si_n = (word16) (ptrArg06 + size_n);
	byte Eq_n::* di_n = (word16) (ptrArg02 + size_n);
	if (wArg0A >> 0x01 < 0x00)
		es_n->*di_n = ds_n->*si_n;
}

// 0800:B05F: void fn0800_B05F(Stack Eq_n ptrArg02, Stack cu16 wArg06, Stack byte bArg08)
// Called from:
//      fn0800_B083
void fn0800_B05F(Eq_n ptrArg02, cu16 wArg06, byte bArg08)
{
	Eq_n di_n = (word16) ptrArg02;
	struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
	cu16 cx_n = wArg06;
	if ((di_n & 0x01) != 0x00)
	{
		if (wArg06 == 0x00)
			return;
		ptrArg02.u1->b0000 = bArg08;
		di_n = (word16) di_n + 1;
		cx_n = wArg06 - 0x01;
	}
	uint16 cx_n = cx_n >> 0x01;
	uint16 cx_n = cx_n;
	while (true)
	{
		word16 ax_n = SEQ(bArg08, bArg08);
		if (cx_n == 0x00)
			break;
		es_n->*di_n = ax_n;
		di_n = (word16) di_n + 2;
		--cx_n;
	}
	if (cx_n < 0x00)
		es_n->*di_n = bArg08;
}

// 0800:B083: void fn0800_B083(Stack Eq_n dwArg02, Stack byte bArg06, Stack cu16 wArg08)
// Called from:
//      fn0800_C379
void fn0800_B083(Eq_n dwArg02, byte bArg06, cu16 wArg08)
{
	fn0800_B05F(dwArg02, wArg08, bArg06);
}

// 0800:B0A1: void fn0800_B0A1(Stack Eq_n ptrArg02, Stack Eq_n ptrArg06, Stack Eq_n wArg0A)
// Called from:
//      fn0800_B0F3
void fn0800_B0A1(Eq_n ptrArg02, Eq_n ptrArg06, Eq_n wArg0A)
{
	struct Eq_n * wArg08 = SLICE(ptrArg06, word16, 16);
	Eq_n wArg06 = (word16) ptrArg06;
	Eq_n wArg04;
	wArg04.u3 = SLICE(ptrArg02, word16, 16);
	Eq_n wArg02 = (word16) ptrArg02;
	word16 cx_n;
	word16 dx_n;
	word16 bx_n;
	fn0800-8F2F(wArg02, wArg08, wArg04, wArg06, out cx_n, out dx_n, out bx_n);
	Eq_n C_n;
	C_n.u0 = <invalid>;
	Eq_n ax_n;
	if (!C_n)
		ax_n.u0 = 0x01;
	else
		ax_n.u0 = 0x00;
	Eq_n si_n = wArg02;
	Eq_n di_n = wArg06;
	Eq_n cx_n = wArg0A;
	if (ax_n != 0x00)
	{
		si_n = wArg02 + wArg0A - 0x01;
		di_n = wArg06 + wArg0A - 0x01;
	}
	if ((di_n & 0x01) != 0x00)
	{
		if (wArg0A == 0x00)
			return;
		wArg08->*di_n = wArg04->*si_n;
		si_n = (word16) si_n + 1;
		di_n = (word16) di_n + 1;
		cx_n = wArg0A - 0x01;
	}
	<unknown>* si_n = si_n - ax_n;
	<unknown>* di_n = di_n - ax_n;
	uint16 cx_n = cx_n >> 0x01;
	memcpy(di_n, si_n, cx_n *32 0x02);
	<unknown> Eq_n::* si_n = (<unknown> Eq_n::*) ((char *) si_n + cx_n * 0x02);
	Eq_n di_n = (char *) di_n + cx_n * 0x02;
	if (cx_n < 0x00)
		wArg08->*(di_n + ax_n) = wArg04->*(si_n + ax_n);
}

// 0800:B0F3: void fn0800_B0F3(Stack Eq_n dwArg02, Stack Eq_n dwArg06, Stack Eq_n wArg0A)
// Called from:
//      fn0800-09A3
//      fn0800-2085
//      fn0800-2201
//      fn0800-22FE
//      fn0800-5D2F
//      fn0800-7FDC
void fn0800_B0F3(Eq_n dwArg02, Eq_n dwArg06, Eq_n wArg0A)
{
	fn0800_B0A1(dwArg06, dwArg02, wArg0A);
}

// 0800:B113: Register Eq_n fn0800_B113(Register Eq_n ds, Stack cui16 wArg02, Stack Eq_n ptrArg04, Register out cui16 cxOut)
// Called from:
//      fn0800_B140
Eq_n fn0800_B113(Eq_n ds, cui16 wArg02, Eq_n ptrArg04, cui16 & cxOut)
{
	Eq_n ax_n;
	if (msdos_create_truncate_file(ptrArg04, wArg02, out ax_n))
		ax_n = fn0800-8D2B(ds, ax_n);
	cxOut = wArg02;
	return ax_n;
}

// 0800:B12E: Register word16 fn0800_B12E(Register Eq_n ds, Stack Eq_n wArg02)
// Called from:
//      fn0800_B140
word16 fn0800_B12E(Eq_n ds, Eq_n wArg02)
{
	word16 ax_n;
	msdos_write_file(wArg02, 0x00, SEQ(ds, 0x00), out ax_n);
	return 0x00;
}

// 0800:B140: Register byte fn0800_B140(Register Eq_n ds, Stack Eq_n dwArg02, Stack cui16 wArg06, Stack cui16 wArg08, Register out word16 cxOut)
// Called from:
//      fn0800_A96D
byte fn0800_B140(Eq_n ds, Eq_n dwArg02, cui16 wArg06, cui16 wArg08, word16 & cxOut)
{
	word16 cx_n;
	cui16 si_n = wArg06;
	if ((wArg06 & 0xC000) == 0x00)
		si_n = wArg06 | Mem15[ds:0x2512:word16] & 0xC000;
	cui16 ax_n = fn0800_A53C(ds, 0x00, out cx_n);
	cui16 wLoc04_n = ax_n;
	Eq_n di_n;
	if ((si_n & 0x0100) != 0x00)
	{
		cui16 di_n = wArg08 & Mem49[ds:9492:word16];
		if ((di_n & 0x0180) == 0x00)
			fn0800-8D2B(ds, 0x01);
		Eq_n wLoc0C_n;
		Eq_n ax_n;
		if (ax_n == ~0x00)
		{
			if (Mem73[ds:9494:word16] != 0x02)
			{
				wLoc0C_n = Mem73[ds:9494:word16];
				goto l0800_B197;
			}
			cui16 ax_n;
			if ((di_n & 0x80) != 0x00)
				ax_n = 0x00;
			else
				ax_n = 0x01;
			wLoc04_n = ax_n;
			if ((si_n & 0xF0) == 0x00)
			{
				Eq_n ax_n = fn0800_B113(ds, ax_n, dwArg02, out cx_n);
				di_n = ax_n;
				if (ax_n < 0x00)
					goto l0800_B298;
l0800_B265:
				if (di_n >= 0x00)
				{
					cui16 ax_n;
					if ((si_n & 0x0300) != 0x00)
						ax_n = 0x1000;
					else
						ax_n = 0x00;
					cui16 dx_n = si_n & ~0x0700 | ax_n;
					cui16 ax_n;
					if ((wLoc04_n & 0x01) != 0x00)
						ax_n = 0x00;
					else
						ax_n = 0x0100;
					(*((word32) ds + 9450))[di_n] = dx_n | ax_n;
				}
				goto l0800_B298;
			}
			Eq_n ax_n = fn0800_B113(ds, 0x00, dwArg02, out cx_n);
			di_n = ax_n;
			Eq_n al_n = (byte) ax_n;
			if (ax_n < 0x00)
			{
l0800_B298:
				ax_n = di_n;
				goto l0800_B29A;
			}
			fn0800_A57F(al_n, ds, ax_n);
		}
		else if ((si_n & 0x0400) != 0x00)
		{
			wLoc0C_n.u0 = 0x50;
l0800_B197:
			ax_n = fn0800-8D2B(ds, wLoc0C_n);
l0800_B29A:
			cxOut = cx_n;
			return (byte) ax_n;
		}
	}
	Eq_n ax_n = fn0800_B2A0(ds, dwArg02, si_n, out cx_n);
	di_n = ax_n;
	if (ax_n >= 0x00)
	{
		cx_n = 0x00;
		word16 cx_n;
		if ((fn0800_A2A3(ds, 0x00, out cx_n) & 0x80) != 0x00)
		{
			si_n |= 0x2000;
			if ((si_n & 0x8000) != 0x00)
				fn0800_A2A3(ds, 0x01, out cx_n);
		}
		else if ((si_n & 0x0200) != 0x00)
			cx_n = fn0800_B12E(ds, ax_n);
		if ((wLoc04_n & 0x01) != 0x00 && ((si_n & 0x0100) != 0x00 && (si_n & 0xF0) != 0x00))
			fn0800_A53C(ds, 0x01, out cx_n);
	}
	goto l0800_B265;
}

// 0800:B2A0: Register Eq_n fn0800_B2A0(Register Eq_n ds, Stack Eq_n ptrArg02, Stack cui16 wArg06, Register out word16 cxOut)
// Called from:
//      fn0800_B140
Eq_n fn0800_B2A0(Eq_n ds, Eq_n ptrArg02, cui16 wArg06, word16 & cxOut)
{
	byte bArg06_n = (byte) wArg06;
	byte al_n = 0x01;
	byte ch_n = SLICE(wArg06, byte, 8);
	if ((wArg06 & 0x02) == 0x00)
	{
		al_n = 0x02;
		if ((wArg06 & 0x04) == 0x00)
			al_n = 0x00;
	}
	word16 cx_n = SEQ(ch_n, bArg06_n & 0xF0);
	Eq_n ax_n;
	Eq_n ax_n;
	if (!msdos_open_file(ptrArg02, al_n | bArg06_n & 0xF0, out ax_n))
	{
		(*((word32) ds + 9450))[ax_n] = wArg06 & ~0x4700 | 0x8000;
		ax_n = ax_n;
	}
	else
		ax_n = fn0800-8D2B(ds, ax_n);
	cxOut = cx_n;
	return ax_n;
}

// 0800:B2EF: Register word16 fn0800_B2EF(Register Eq_n cx, Register Eq_n dx, Register Eq_n bx, Register Eq_n ds, Stack Eq_n dwArg02, Register out word16 diOut)
// Called from:
//      main
//      fn0800-0ABC
//      fn0800-0C93
//      fn0800-0D24
//      fn0800-0DCE
//      fn0800-0DE8
//      fn0800-112D
//      fn0800-12E2
//      fn0800-18D9
//      fn0800-19EE
//      fn0800-2DE2
//      fn0800-6EE6
//      fn0800-6EFF
//      fn0800-75EA
//      fn0800-7FDC
word16 fn0800_B2EF(Eq_n cx, Eq_n dx, Eq_n bx, Eq_n ds, Eq_n dwArg02, word16 & diOut)
{
	word16 di_n;
	mp16 fp;
	word16 si_n = fn0800-9828(cx, dx, bx, ds, fp + 6, dwArg02, out di_n);
	diOut = di_n;
	return si_n;
}

// 0800:B30A: Register word16 fn0800_B30A(Register Eq_n ds, Stack Eq_n bArg02, Stack Eq_n ptrArg04, Register out word16 cxOut, Register out word16 dxOut, Register out word16 bxOut)
// Called from:
//      fn0800-4047
//      fn0800_B4BE
word16 fn0800_B30A(Eq_n ds, Eq_n bArg02, Eq_n ptrArg04, word16 & cxOut, word16 & dxOut, word16 & bxOut)
{
	word16 bx_n;
	word16 dx_n;
	word16 cx_n;
	ptrArg04.u5->t0000.u1.u2 = (uint16) (ptrArg04.u5->t0000.u1.u2 - 0x01);
	word16 ax_n = fn0800_B324(ds, bArg02, ptrArg04, out cx_n, out dx_n, out bx_n);
	cxOut = cx_n;
	dxOut = dx_n;
	bxOut = bx_n;
	return ax_n;
}

// 0800:B324: Register uint16 fn0800_B324(Register Eq_n ds, Stack Eq_n bArg02, Stack Eq_n ptrArg04, Register out word16 cxOut, Register out word16 dxOut, Register out word16 bxOut)
// Called from:
//      fn0800_B30A
//      fn0800_B4BE
uint16 fn0800_B324(Eq_n ds, Eq_n bArg02, Eq_n ptrArg04, word16 & cxOut, word16 & dxOut, word16 & bxOut)
{
	word16 dx;
	byte dh = SLICE(dx, byte, 8);
	word16 wArg04_n = (word16) ptrArg04;
	word16 wArg06_n = SLICE(ptrArg04, word16, 16);
	Mem14[ds:0x4EE6:byte] = bArg02;
	word16 bx_n = (word16) ptrArg04;
	word16 dx_n;
	word16 cx;
	if (ptrArg04.u5->t0000.u1.u2 >= ~0x00)
	{
		dx_n = dx;
		if ((ptrArg04.u5->t0002.u1.u2 & 0x90) == 0x00)
		{
			dx_n = dx;
			if ((ptrArg04.u5->t0002.u1.u2 & 0x02) != 0x00)
			{
				ptrArg04.u5->t0002.u1.u2 |= 0x0100;
				word16 wArg06_n;
				if (ptrArg04.u5->t0006.u2 != 0x00)
				{
					if (ptrArg04.u5->t0000.u1.u2 != 0x00)
					{
						dh = SLICE(dx_n, byte, 8);
						cx = wArg06_n;
						if (fn0800_A6B7(ds, ptrArg04, out dx_n, out bx_n) != 0x00)
							goto l0800_B380;
					}
					ptrArg04.u5->t0000.u1.u2 = (uint16) -ptrArg04.u5->t0006.u2;
					struct Eq_n * ax_n = ptrArg04.u5->t000E.u2;
					union Eq_n Eq_n::* si_n = (union Eq_n Eq_n::*) ptrArg04.u5->t000C.u2;
					ptrArg04.u5->t000C.u2 = (uint16) (ptrArg04.u5->t000C.u2 + 0x01);
					Eq_n dl_n = Mem193[ds:0x4EE6:byte];
					(ax_n->*si_n).u0 = (int8) dl_n;
					bx_n = wArg04_n;
					dx_n = SEQ(dh, dl_n);
					if ((ptrArg04.u5->t0002.u1.u2 & 0x08) == 0x00 || Mem197[ds:0x4EE6:byte] != 0x0A && Mem197[ds:0x4EE6:byte] != 0x0D)
						goto l0800_B4A3;
					cx = wArg06_n;
					uint16 ax_n;
					if (fn0800_A6B7(ds, ptrArg04, out dx_n, out bx_n) == 0x00)
					{
l0800_B4A3:
						ax_n = CONVERT(Mem300[ds:0x4EE6:byte], uint8, uint16);
						goto l0800_B4A8;
					}
l0800_B380:
					ax_n = ~0x00;
l0800_B4A8:
					cxOut = cx;
					dxOut = dx_n;
					bxOut = bx_n;
					return ax_n;
				}
				if (((*((word32) ds + 9450))[(int16) ptrArg04.u5->t0004.u0] & 0x0800) != 0x00)
				{
					word16 cx_n;
					word16 dx_n;
					fn0800-8E29(ds, (int16) ptrArg04.u5->t0004.u0, 0x00, 0x02, out cx_n, out dx_n);
					wArg06_n = SLICE(ptrArg04, word16, 16);
				}
				word16 bx_n;
				if ((Mem77[ds:0x4EE6:byte] != 0x0A || (((((ptrArg04.u5)->t0002).u1).u2 & 0x40) != 0x00 || fn0800_C779(ds, (int16) ((ptrArg04.u5)->t0004).u0, SEQ(ds, 9902), 0x01, out cx, out dx_n, out bx_n) == 0x01)) && fn0800_C779(ds, (int16) ((ptrArg04.u5)->t0004).u0, SEQ(ds, 0x4EE6), 0x01, out cx, out dx_n, out bx_n) == 0x01)
					goto l0800_B4A3;
				bx_n = (word16) ptrArg04;
				if ((ptrArg04.u5->t0002.u1.u2 & 0x0200) != 0x00)
					goto l0800_B4A3;
			}
		}
		ptrArg04.u5->t0002.u1.u2 |= 0x10;
		bx_n = (word16) ptrArg04;
		goto l0800_B380;
	}
	else
	{
		ptrArg04.u5->t0000.u1.u2 = (uint16) (ptrArg04.u5->t0000.u1.u2 + 0x01);
		struct Eq_n * ax_n = ptrArg04.u5->t000E.u2;
		union Eq_n Eq_n::* si_n = (union Eq_n Eq_n::*) ptrArg04.u5->t000C.u2;
		ptrArg04.u5->t000C.u2 = (uint16) (ptrArg04.u5->t000C.u2 + 0x01);
		Eq_n dl_n = Mem254[ds:0x4EE6:byte];
		(ax_n->*si_n).u0 = (int8) dl_n;
		dx_n = SEQ(dh, dl_n);
		if ((ptrArg04.u5->t0002.u1.u2 & 0x08) == 0x00 || Mem257[ds:0x4EE6:byte] != 0x0A && Mem257[ds:0x4EE6:byte] != 0x0D)
			goto l0800_B4A3;
		cx = wArg06_n;
		if (fn0800_A6B7(ds, ptrArg04, out dx_n, out bx_n) == 0x00)
			goto l0800_B4A3;
		goto l0800_B380;
	}
}

// 0800:B4BE: Register Eq_n fn0800_B4BE(Register Eq_n ds, Stack Eq_n ptrArg02, Stack Eq_n wArg06, Stack Eq_n ptrArg08)
// Called from:
//      fn0800_AD85
Eq_n fn0800_B4BE(Eq_n ds, Eq_n ptrArg02, Eq_n wArg06, Eq_n ptrArg08)
{
	Eq_n di_n = wArg06;
	Eq_n ptrArg08_n;
	if ((ptrArg02.u5->t0002.u1.u2 & 0x08) != 0x00)
	{
		Eq_n ptrArg08_n;
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		do
		{
			word16 wArg08_n = (word16) ptrArg08_n;
			word16 wArg0A_n = SLICE(ptrArg08_n, word16, 16);
			--di_n;
			if (di_n == 0x00)
				goto l0800_B69D;
			ptrArg08_n = SEQ(wArg0A_n, wArg08_n + 0x01);
			ptrArg08_n = ptrArg08_n;
		} while (fn0800_B324(ds, *ptrArg08_n.u3, ptrArg02, out cx_n, out dx_n, out bx_n) != ~0x00);
		goto l0800_B4F5;
	}
	Eq_n ax_n;
	if ((ptrArg02.u5->t0002.u1.u2 & 0x40) == 0x00)
	{
		ptrArg08_n = ptrArg08;
		if (ptrArg02.u5->t0006.u2 != 0x00)
		{
			uint16 ax_n;
			do
			{
				word16 wArg08_n = (word16) ptrArg08_n;
				word16 wArg0A_n = SLICE(ptrArg08_n, word16, 16);
				--di_n;
				if (di_n == 0x00)
					goto l0800_B69D;
				Eq_n v23_n = ptrArg02.u5->t0000.u1.u2 + 0x01;
				ptrArg02.u5->t0000.u1.u2 = (uint16) v23_n;
				if (v23_n < 0x00)
				{
					Eq_n ax_n;
					ax_n.u2 = ptrArg02.u5->t000E.u2;
					Eq_n si_n;
					si_n.u2 = ptrArg02.u5->t000C.u2;
					ptrArg02.u5->t000C.u2 = (uint16) (ptrArg02.u5->t000C.u2 + 0x01);
					Eq_n dl_n;
					dl_n.u3 = *ptrArg08_n.u3;
					ax_n->*si_n.u3 = (char) dl_n;
					ax_n = (uint16) dl_n;
					ptrArg08_n = SEQ(wArg0A_n, wArg08_n + 0x01);
				}
				else
				{
					word16 cx_n;
					word16 dx_n;
					word16 bx_n;
					ax_n = fn0800_B30A(ds, *ptrArg08_n.u3, ptrArg02, out cx_n, out dx_n, out bx_n);
					ptrArg08_n = SEQ(wArg0A_n, wArg08_n + 0x01);
				}
			} while (ax_n != ~0x00);
			goto l0800_B4F5;
		}
		word16 dx_n;
		word16 bx_n;
		if (fn0800_C632(ds, (int16) ptrArg02.u5->t0004.u0, ptrArg08, wArg06, out dx_n, out bx_n) < wArg06)
			goto l0800_B4F5;
	}
	else if (ptrArg02.u5->t0006.u2 == 0x00)
	{
		if (((*((word32) ds + 9450))[(int16) ptrArg02.u5->t0004.u0] & 0x0800) != 0x00)
		{
			word16 cx_n;
			word16 dx_n;
			fn0800-8E29(ds, (int16) ptrArg02.u5->t0004.u0, 0x00, 0x02, out cx_n, out dx_n);
		}
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		if (fn0800_C779(ds, (int16) ptrArg02.u5->t0004.u0, ptrArg08, wArg06, out cx_n, out dx_n, out bx_n) < wArg06)
			goto l0800_B4F5;
	}
	else if (ptrArg02.u5->t0006.u2 < wArg06)
	{
		word16 dx_n;
		word16 bx_n;
		if (ptrArg02.u5->t0000.u1.u2 != 0x00 && fn0800_A6B7(ds, ptrArg02, out dx_n, out bx_n) != 0x00)
			goto l0800_B4F5;
		if (((*((word32) ds + 9450))[(int16) ptrArg02.u5->t0004.u0] & 0x0800) != 0x00)
		{
			word16 cx_n;
			word16 dx_n;
			fn0800-8E29(ds, (int16) ptrArg02.u5->t0004.u0, 0x00, 0x02, out cx_n, out dx_n);
		}
		word16 cx_n;
		word16 dx_n;
		word16 bx_n;
		if (fn0800_C779(ds, (int16) ptrArg02.u5->t0004.u0, ptrArg08, wArg06, out cx_n, out dx_n, out bx_n) < wArg06)
		{
l0800_B4F5:
			ax_n.u0 = 0x00;
			return ax_n;
		}
	}
	else
	{
		if (wArg06.u3 + (((ptrArg02.u5)->t0000).u1).u2 >= 0x00)
		{
			if (ptrArg02.u5->t0000.u1.u2 == 0x00)
				ptrArg02.u5->t0000.u1.u2 = (uint16) (~0x00 - ((ptrArg02.u5)->t0006).u2);
			else
			{
				word16 dx_n;
				word16 bx_n;
				if (fn0800_A6B7(ds, ptrArg02, out dx_n, out bx_n) != 0x00)
					goto l0800_B4F5;
			}
		}
		fn0800_B03B(ptrArg02.u5->t000C.u3, ptrArg08, wArg06);
		ptrArg02.u5->t0000.u1.u2 = (uint16) (wArg06.u3 + (((ptrArg02.u5)->t0000).u1).u2);
		ptrArg02.u5->t000C.u2 = (uint16) (wArg06.u3 + ((ptrArg02.u5)->t000C).u2);
	}
l0800_B69D:
	ax_n = wArg06;
	return ax_n;
}

// 0800:B6A8: void fn0800_B6A8(Register Eq_n ds, Stack Eq_n ptrArg02, Stack Eq_n ptrArg06)
// Called from:
//      fn0800_B6D6
void fn0800_B6A8(Eq_n ds, Eq_n ptrArg02, Eq_n ptrArg06)
{
	Eq_n cx_n = Mem17[ds:20200:word16];
	struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
	word16 Eq_n::* di_n = (word16) ptrArg02;
	struct Eq_n * ds_n = SLICE(ptrArg06, selector, 16);
	struct Eq_n Eq_n::* si_n = (word16) ptrArg06;
	uint16 cx_n = cx_n >> 0x01;
	if (cx_n >> 0x01 < 0x00)
	{
		Eq_n al_n;
		al_n.u3 = *ptrArg02.u3;
		*ptrArg02.u3 = *ptrArg06.u3;
		*ptrArg06.u3 = (char) al_n;
		si_n = (struct Eq_n Eq_n::*) ((char *) &si_n->w0000 + 1);
		di_n = (word16 Eq_n::*) ((char *) di_n + 1);
		if (cx_n >> 0x01 == 0x00)
			return;
	}
	do
	{
		word16 ax_n = es_n->*di_n;
		es_n->*di_n = (ds_n->*si_n).w0000;
		++si_n;
		(ds_n->*si_n).wFFFFFFFE = ax_n;
		++di_n;
		--cx_n;
	} while (cx_n != 0x00);
}

// 0800:B6D6: void fn0800_B6D6(Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n wArg04, Stack Eq_n wArg06)
// Called from:
//      fn0800_B6D6
//      fn0800_B95E
void fn0800_B6D6(Eq_n ds, Eq_n wArg02, Eq_n wArg04, Eq_n wArg06)
{
	word16 cx_n;
	word16 cx_n;
	struct Eq_n Eq_n::* sp_n;
	mp16 fp;
	struct Eq_n Eq_n::* sp_n = fp - 0x1A;
	Eq_n si_n = wArg02;
	selector ss;
	struct Eq_n Eq_n::* sp_n;
	while (si_n > 0x02)
	{
		Eq_n bx_n = wArg04 + Mem24[ds:20200:word16] *s (si_n - 0x01);
		int16 ax_n = Mem33[ds:20200:word16] *s (si_n >>u 0x01);
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		(ss->*sp_n).t0000.u2 = (uint16) wArg06;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) bx_n;
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) wArg06;
		Eq_n bx_n;
		bx_n.u3 = wArg04.u3 + ax_n;
		(ss->*sp_n).tFFFFFFFA.u2 = (uint16) bx_n;
		0x0800:Mem55[ds:20202:word16]();
		Eq_n wLoc0A_n = bx_n;
		ci16 ax_n;
		struct Eq_n Eq_n::* sp_n;
		if (ax_n > 0x00)
		{
			(ss->*sp_n).t0006.u2 = (uint16) wArg06;
			(ss->*sp_n).t0004.u2 = (uint16) bx_n;
			(ss->*sp_n).t0002.u2 = (uint16) wArg06;
			(ss->*sp_n).t0000.u2 = (uint16) bx_n;
			fn0800_B6A8(ds, (ss->*sp_n).t0000.u3, (ss->*sp_n).t0004.u3);
		}
		(ss->*sp_n).t0006.u2 = (uint16) wArg06;
		(ss->*sp_n).t0004.u2 = (uint16) wArg04;
		(ss->*sp_n).t0002.u2 = (uint16) wArg06;
		(ss->*sp_n).t0000.u2 = (uint16) bx_n;
		0x0800:Mem106[ds:20202:word16]();
		ci16 ax_n;
		struct Eq_n Eq_n::* sp_n;
		struct Eq_n Eq_n::* sp_n;
		if (ax_n > 0x00)
		{
			(ss->*sp_n).t0006.u2 = (uint16) wArg06;
			(ss->*sp_n).t0004.u2 = (uint16) bx_n;
			(ss->*sp_n).t0002.u2 = (uint16) wArg06;
			(ss->*sp_n).t0000.u2 = (uint16) wArg04;
			sp_n = sp_n;
			goto l0800_B7BD;
		}
		(ss->*sp_n).t0006.u2 = (uint16) wArg06;
		(ss->*sp_n).t0004.u2 = (uint16) bx_n;
		(ss->*sp_n).t0002.u2 = (uint16) wArg06;
		(ss->*sp_n).t0000.u2 = (uint16) wArg04;
		0x0800:Mem135[ds:20202:word16]();
		struct Eq_n Eq_n::* sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0006 + 2);
		ci16 ax_n;
		if (ax_n > 0x00)
		{
			(ss->*sp_n).t0006.u2 = (uint16) wArg06;
			(ss->*sp_n).t0004.u2 = (uint16) wArg04;
			(ss->*sp_n).t0002.u2 = (uint16) wArg06;
			(ss->*sp_n).t0000.u2 = (uint16) bx_n;
			sp_n = sp_n;
l0800_B7BD:
			fn0800_B6A8(ds, (ss->*sp_n).t0000.u3, (ss->*sp_n).t0004.u3);
			sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0006 + 2);
		}
		if (si_n == 0x03)
		{
			struct Eq_n Eq_n::* sp_n = sp_n - 2;
			(ss->*sp_n).t0000.u2 = (uint16) wArg06;
			(ss->*sp_n).tFFFFFFFE.u2 = (uint16) wArg04;
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) wArg06;
			(ss->*sp_n).tFFFFFFFA.u2 = (uint16) bx_n;
			sp_n = sp_n - 6;
			goto l0800_B720;
		}
		Eq_n dx_n = wArg04 + Mem193[ds:20200:word16];
		Eq_n wLoc0E_n = dx_n;
		Eq_n wLoc06_n = dx_n;
		do
		{
			struct Eq_n Eq_n::* sp_n = sp_n - 2;
			(ss->*sp_n).t0000.u2 = (uint16) wArg06;
			(ss->*sp_n).tFFFFFFFE.u2 = (uint16) wArg04;
			(ss->*sp_n).tFFFFFFFC.u2 = (uint16) wArg06;
			(ss->*sp_n).tFFFFFFFA.u2 = (uint16) wLoc06_n;
			0x0800:Mem218[ds:20202:word16]();
			struct Eq_n Eq_n::* sp_n;
			sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0006 + 2);
			ci16 ax_n;
			if (ax_n <= 0x00)
			{
				if (ax_n == 0x00)
				{
					(ss->*sp_n).t0006.u2 = (uint16) wArg06;
					(ss->*sp_n).t0004.u2 = (uint16) wLoc06_n;
					(ss->*sp_n).t0002.u2 = (uint16) wArg06;
					(ss->*sp_n).t0000.u2 = (uint16) wLoc0E_n;
					fn0800_B6A8(ds, (ss->*sp_n).t0000.u3, (ss->*sp_n).t0004.u3);
					wLoc0E_n += Mem253[ds:20200:word16];
				}
				sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0006 + 2);
				if (wLoc06_n >= wLoc0A_n)
					break;
				wLoc06_n += Mem269[ds:20200:word16];
				continue;
			}
			if (wLoc06_n < wLoc0A_n)
			{
				Eq_n v62_n;
				do
				{
					struct Eq_n Eq_n::* sp_n = sp_n - 2;
					(ss->*sp_n).t0000.u2 = (uint16) wArg06;
					(ss->*sp_n).tFFFFFFFE.u2 = (uint16) wLoc0A_n;
					(ss->*sp_n).tFFFFFFFC.u2 = (uint16) wArg06;
					(ss->*sp_n).tFFFFFFFA.u2 = (uint16) wArg04;
					0x0800:Mem296[ds:20202:word16]();
					struct Eq_n Eq_n::* sp_n;
					sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0006 + 2);
					ci16 ax_n;
					if (ax_n >= 0x00)
					{
						(ss->*sp_n).t0006.u2 = (uint16) wArg06;
						(ss->*sp_n).t0004.u2 = (uint16) wLoc06_n;
						(ss->*sp_n).t0002.u2 = (uint16) wArg06;
						(ss->*sp_n).t0000.u2 = (uint16) wLoc0A_n;
						fn0800_B6A8(ds, (ss->*sp_n).t0000.u3, (ss->*sp_n).t0004.u3);
						sp_n = (struct Eq_n Eq_n::*) ((char *) &sp_n->t0006 + 2);
						if (ax_n != 0x00)
						{
							Eq_n ax_n = Mem327[ds:20200:word16];
							wLoc06_n.u3 = wLoc06_n + ax_n;
							wLoc0A_n -= ax_n;
						}
						break;
					}
					v62_n = wLoc0A_n - Mem296[ds:20200:word16];
					wLoc0A_n = v62_n;
				} while (wLoc06_n < v62_n);
			}
		} while (wLoc06_n < wLoc0A_n);
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		(ss->*sp_n).t0000.u2 = (uint16) wArg06;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) wArg04;
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) wArg06;
		(ss->*sp_n).tFFFFFFFA.u2 = (uint16) wLoc06_n;
		0x0800:Mem378[ds:20202:word16]();
		ci16 ax_n;
		if (ax_n <= 0x00)
			wLoc06_n += Mem378[ds:20200:word16];
		Eq_n wLoc16_n = wLoc06_n - Mem411[ds:20200:word16];
		Eq_n wLoc12_n = wArg04;
		struct Eq_n Eq_n::* sp_n;
		while (wLoc12_n < wLoc0E_n && wLoc16_n >= wLoc0E_n)
		{
			(ss->*sp_n).t0006.u2 = (uint16) wArg06;
			(ss->*sp_n).t0004.u2 = (uint16) wLoc12_n;
			(ss->*sp_n).t0002.u2 = (uint16) wArg06;
			(ss->*sp_n).t0000.u2 = (uint16) wLoc16_n;
			fn0800_B6A8(ds, (ss->*sp_n).t0000.u3, (ss->*sp_n).t0004.u3);
			Eq_n ax_n = Mem444[ds:20200:word16];
			wLoc12_n.u3 = wLoc12_n + ax_n;
			wLoc16_n -= ax_n;
		}
		(ss->*sp_n).t0006.u2 = (uint16) 0x00;
		Mem469[ss:sp_n + 0x04:word16] = Mem465[ds:20200:word16];
		(ss->*sp_n).t0002.u2 = (uint16) 0x00;
		(ss->*sp_n).t0000.u2 = (uint16) (wLoc06_n - wLoc0E_n);
		Eq_n ax_n = (word16) fn0800-8BBB((ss->*sp_n).tFFFFFFFE.u3, (ss->*sp_n).t0002.u3, out cx_n);
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) 0x00;
		Mem497[ss:sp_n + -4:word16] = Mem494[ds:20200:word16];
		word16 dx_n = wArg04 + Mem497[ds:20200:word16] *s16 si_n - wLoc06_n;
		(ss->*sp_n).tFFFFFFFA.u2 = (uint16) 0x00;
		(ss->*sp_n).wFFFFFFF8 = dx_n;
		Eq_n ax_n = (word16) fn0800-8BBB((ss->*sp_n).tFFFFFFF6.u3, (ss->*sp_n).tFFFFFFFA.u3, out cx_n);
		si_n = ax_n;
		if (ax_n < ax_n)
		{
			(ss->*sp_n).tFFFFFFF6.u2 = (uint16) wArg06;
			(ss->*sp_n).tFFFFFFF4.u2 = (uint16) wLoc06_n;
			(ss->*sp_n).tFFFFFFF2.u2 = (uint16) ax_n;
			// Failed to bind call argument.
			// Please report this issue at https://github.com/uxmal/reko
			// Failed to bind call argument.
			// Please report this issue at https://github.com/uxmal/reko
			// Failed to bind call argument.
			// Please report this issue at https://github.com/uxmal/reko
			Eq_n stackArg2;
			stackArg2.u0 = <invalid>;
			Eq_n stackArg4;
			stackArg4.u0 = <invalid>;
			Eq_n stackArg6;
			stackArg6.u0 = <invalid>;
			fn0800_B6D6(ds, stackArg2, stackArg4, stackArg6);
			sp_n = sp_n - 0x08;
			si_n = ax_n;
		}
		else
		{
			(ss->*sp_n).tFFFFFFF6.u2 = (uint16) wArg06;
			(ss->*sp_n).tFFFFFFF4.u2 = (uint16) wArg04;
			(ss->*sp_n).tFFFFFFF2.u2 = (uint16) ax_n;
			// Failed to bind call argument.
			// Please report this issue at https://github.com/uxmal/reko
			// Failed to bind call argument.
			// Please report this issue at https://github.com/uxmal/reko
			// Failed to bind call argument.
			// Please report this issue at https://github.com/uxmal/reko
			Eq_n stackArg2;
			stackArg2.u0 = <invalid>;
			Eq_n stackArg4;
			stackArg4.u0 = <invalid>;
			Eq_n stackArg6;
			stackArg6.u0 = <invalid>;
			fn0800_B6D6(ds, stackArg2, stackArg4, stackArg6);
			sp_n = sp_n - 0x08;
			wArg04 = wLoc06_n;
		}
	}
	if (si_n == 0x02)
	{
		Eq_n dx_n = wArg04 + Mem24[ds:20200:word16];
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		(ss->*sp_n).t0000.u2 = (uint16) wArg06;
		(ss->*sp_n).tFFFFFFFE.u2 = (uint16) dx_n;
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) wArg06;
		(ss->*sp_n).tFFFFFFFA.u2 = (uint16) wArg04;
		0x0800:Mem598[ds:20202:word16]();
		ci16 ax_n;
		if (ax_n > 0x00)
		{
			struct Eq_n Eq_n::* sp_n;
			(ss->*sp_n).t0006.u2 = (uint16) wArg06;
			(ss->*sp_n).t0004.u2 = (uint16) wArg04;
			(ss->*sp_n).t0002.u2 = (uint16) wArg06;
			(ss->*sp_n).t0000.u2 = (uint16) dx_n;
			sp_n = sp_n;
l0800_B720:
			fn0800_B6A8(ds, (ss->*sp_n).t0000.u3, (ss->*sp_n).t0004.u3);
		}
	}
}

// 0800:B95E: void fn0800_B95E(Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n wArg04, Stack Eq_n wArg06, Stack Eq_n wArg08, Stack Eq_n wArg0A)
// Called from:
//      fn0800-5E64
void fn0800_B95E(Eq_n ds, Eq_n wArg02, Eq_n wArg04, Eq_n wArg06, Eq_n wArg08, Eq_n wArg0A)
{
	Mem11[ds:20200:word16] = wArg08;
	if (wArg08 != 0x00)
	{
		Mem18[ds:20202:word16] = wArg0A;
		fn0800_B6D6(ds, wArg06, wArg02, wArg04);
	}
}

// 0800:B97F: Register Eq_n fn0800_B97F(Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n ptrArg04, Stack Eq_n wArg08)
// Called from:
//      fn0800_AE4C
//      fn0800_AED6
Eq_n fn0800_B97F(Eq_n ds, Eq_n wArg02, Eq_n ptrArg04, Eq_n wArg08)
{
	byte ch_n;
	struct Eq_n * wArg06 = SLICE(ptrArg04, word16, 16);
	Eq_n wArg04 = (word16) ptrArg04;
	Eq_n ax_n;
	if (wArg02 >=u Mem15[ds:9448:word16])
		ax_n = fn0800-8D2B(ds, 0x06);
	else if (wArg08 >= 0x01 && ((*((word32) ds + 9450))[wArg02] & 0x0200) == 0x00)
	{
		Eq_n di_n;
		do
		{
			Eq_n ax_n = fn0800-8F50(ds, wArg02, ptrArg04, wArg08, out ch_n);
			if (ax_n < 0x01 || ((*((word32) ds + 9450))[wArg02] & 0x4000) == 0x00)
			{
				ax_n = ax_n;
				return ax_n;
			}
			Eq_n cx_n = ax_n;
			Eq_n si_n = wArg04;
			di_n = wArg04;
			do
			{
				byte al_n = (byte) (wArg06->*si_n);
				si_n = (word16) si_n + 1;
				if (al_n == 0x1A)
				{
					word16 cx_n;
					word16 dx_n;
					fn0800-8E29(ds, wArg02, SEQ(0x00 - (word16) (cx_n != 0x00), -cx_n), 0x01, out cx_n, out dx_n);
					(*((word32) ds + 9450))[wArg02] |= 0x0200;
					goto l0800_BA41;
				}
				if (al_n != 0x0D)
				{
					wArg06->*di_n = al_n;
					di_n = (word16) di_n + 1;
					--cx_n;
					if (cx_n == 0x00)
						goto l0800_BA19;
					continue;
				}
				--cx_n;
			} while (cx_n != 0x00);
			<unknown> Eq_n::* fp;
			byte ch_n;
			fn0800-8F50(ds, wArg02, fp - 5, 0x01, out ch_n);
			byte bLoc05;
			wArg06->*di_n = bLoc05;
			di_n = (word16) di_n + 1;
l0800_BA19:
		} while (di_n == wArg04);
l0800_BA41:
		ax_n = di_n - wArg04;
	}
	else
		ax_n.u0 = 0x00;
	return ax_n;
}

// 0800:BA4A: Register Eq_n fn0800_BA4A(Register Eq_n ds, Stack Eq_n ptrArg02, Stack Eq_n ptrArg06)
// Called from:
//      fn0800-37DF
//      fn0800-3C99
Eq_n fn0800_BA4A(Eq_n ds, Eq_n ptrArg02, Eq_n ptrArg06)
{
	Eq_n ax_n;
	Eq_n ax_n;
	if (!msdos_rename_file(ptrArg02, ptrArg06, out ax_n))
		ax_n.u0 = 0x00;
	else
		ax_n = fn0800-8D2B(ds, ax_n);
	return ax_n;
}

// 0800:BA67: void fn0800_BA67(Register Eq_n ds, Stack Eq_n ptrArg02)
// Called from:
//      fn0800-0DE8
//      fn0800-12E2
//      fn0800-3BC3
void fn0800_BA67(Eq_n ds, Eq_n ptrArg02)
{
	word16 cx_n;
	if (fn0800_ACB3(ds, ptrArg02, 0x00, 0x00, out cx_n) == 0x00)
		ptrArg02.u5->t0002.u1.u2 &= ~0x10;
}

// 0800:BA89: Register word16 fn0800_BA89(Register Eq_n ds, Stack Eq_n ptrArg02, Stack cui16 wArg06, Stack cui16 wArg08, Stack ci16 wArg0A, Stack Eq_n wArg0C, Register out Eq_n cxOut, Register out Eq_n dsOut)
// Called from:
//      fn0800_A96D
word16 fn0800_BA89(Eq_n ds, Eq_n ptrArg02, cui16 wArg06, cui16 wArg08, ci16 wArg0A, Eq_n wArg0C, union Eq_n & cxOut, union Eq_n & dsOut)
{
	cui16 dx_n;
	mp16 fp;
	word16 wArg02_n = (word16) ptrArg02;
	struct Eq_n Eq_n::* bp_n = fp - 2;
	ci16 di_n = wArg0A;
	word16 ax_n;
	if (ptrArg02.u5->w0012 != wArg02_n || (wArg0A > 0x02 || wArg0C > 0x7FFF))
	{
l0800_BAAB:
		ax_n = ~0x00;
		goto l0800_BB94;
	}
	else
	{
		if (Mem14[ds:0x26B2:word16] == 0x00 && wArg02_n == 0x236C)
			Mem41[ds:0x26B2:word16] = 0x01;
		else if (Mem14[ds:9904:word16] == 0x00 && wArg02_n == 0x2358)
			Mem40[ds:9904:word16] = 0x01;
		Eq_n cx;
		if (ptrArg02.u5->t0000.u1.u2 != 0x00)
			fn0800_ACB3(ds, ptrArg02, 0x00, 0x01, out cx);
		Eq_n wArg04_n;
		wArg04_n.u3 = SLICE(ptrArg02, word16, 16);
		word16 wArg02_n = (word16) ptrArg02;
		if ((ptrArg02.u5->t0002.u1.u2 & 0x04) != 0x00)
		{
			Eq_n v22_n;
			v22_n.u2 = ptrArg02.u5->t000A.u2;
			word16 cx_n;
			word16 dx_n;
			word16 bx_n;
			fn0800-9E75(ds, v22_n, out cx_n, out dx_n, out bx_n, out ds);
			cx = v22_n;
		}
		ptrArg02.u5->t0002.u1.u2 = (uint16) (ptrArg02.u5->t0002.u1.u2 & ~0x0C);
		ptrArg02.u5->t0006.u2 = (uint16) 0x00;
		ptrArg02.u5->t000A.u2 = (uint16) wArg04_n;
		ptrArg02.u5->t0008.u2 = (uint16) (wArg02_n + 0x05);
		ptrArg02.u5->t000E.u2 = (uint16) wArg04_n;
		ptrArg02.u5->t000C.u2 = (uint16) (wArg02_n + 0x05);
		if (wArg0A != 0x02)
		{
			Eq_n si_n = wArg0C;
			if (wArg0C > 0x00)
			{
				Mem147[ds:0x2352:word16] = ~0x380F;
				selector ss;
				if ((wArg06 | wArg08) == 0x00)
				{
					cui16 ax_n = fn0800-9F7F(ds, wArg0C, out dx_n, out bp_n, out si_n, out di_n, out ds);
					(ss->*bp_n).w000A = dx_n;
					(ss->*bp_n).w0008 = ax_n;
					cx = wArg0C;
					if ((ax_n | dx_n) == 0x00)
						goto l0800_BAAB;
					struct Eq_n * es_bx_n = (ss->*bp_n).ptr0004;
					es_bx_n->w0002 |= 0x04;
				}
				struct Eq_n * es_bx_n = (ss->*bp_n).ptr0004;
				cui16 ax_n = (ss->*bp_n).w000A;
				cui16 dx_n = (ss->*bp_n).w0008;
				es_bx_n->w000E = ax_n;
				es_bx_n->w000C = dx_n;
				es_bx_n->w000A = ax_n;
				es_bx_n->w0008 = dx_n;
				es_bx_n->t0006.u2 = (uint16) si_n;
				if (di_n == 0x01)
					es_bx_n->w0002 |= 0x08;
			}
		}
		ax_n = 0x00;
l0800_BB94:
		cxOut = cx;
		dsOut = ds;
		return ax_n;
	}
}

// 0800:BB98: void fn0800_BB98(Stack Eq_n wArg02, Stack Eq_n dwArg04, Stack Eq_n ptrArg08)
void fn0800_BB98(Eq_n wArg02, Eq_n dwArg04, Eq_n ptrArg08)
{
	if (ptrArg08 != 0x00)
	{
		word16 cx_n;
		if (fn0800_BFC7(dwArg04, out cx_n) >= wArg02)
		{
			fn0800_C01E(ptrArg08, dwArg04, wArg02);
			*(ptrArg08 + wArg02) = (ptr32) 0x00;
		}
		else
			fn0800_BF9E(ptrArg08, dwArg04);
	}
}

// 0800:BBE9: void fn0800_BBE9(Stack (ptr32 Eq_n) ptrArg02)
void fn0800_BBE9(struct Eq_n * ptrArg02)
{
	word16 wArg02_n = (word16) ptrArg02;
	word16 wArg04_n = SLICE(ptrArg02, word16, 16);
	if (ptrArg02->bFFFFFFFF == 0x2E)
		--wArg02_n;
	int8 * ptrArg02_n = SEQ(wArg04_n, wArg02_n - 0x01);
	int16 ax_n = (int16) *ptrArg02_n;
	word16 cx_n;
	struct Eq_n seg0800_t::* bx_n = &seg0800_t::tBC39;
	for (cx_n = 0x04; cx_n != 0x00; --cx_n)
	{
		if ((0x0800->*bx_n).w0000 == ax_n)
		{
			bx_n[4]();
			return;
		}
		++bx_n;
	}
}

Eq_n g_tBC39 = // 0800:BC39
	{
		0x00,
		
		{
			0xBC2C
		},
	};
// 0800:BC49: Register word16 fn0800_BC49(Stack Eq_n ptrArg02, Stack Eq_n ptrArg06, Stack Eq_n ptrArg0A, Stack Eq_n ptrArg0E, Stack Eq_n ptrArg12)
// Called from:
//      fn0800_BE3B
word16 fn0800_BC49(Eq_n ptrArg02, Eq_n ptrArg06, Eq_n ptrArg0A, Eq_n ptrArg0E, Eq_n ptrArg12)
{
	word16 cx_n;
	<unknown> Eq_n::* fp;
	word16 wArg06 = (word16) ptrArg06;
	word16 wArg08 = SLICE(ptrArg06, word16, 16);
	word16 wArg0A = (word16) ptrArg0A;
	word16 wArg0C = SLICE(ptrArg0A, word16, 16);
	word16 wArg0E = (word16) ptrArg0E;
	word16 wArg10 = SLICE(ptrArg0E, word16, 16);
	word16 wArg12 = (word16) ptrArg12;
	word16 wArg14 = SLICE(ptrArg12, word16, 16);
	if (ptrArg06 != 0x00)
		*ptrArg06.u1 = 0x00;
	if (ptrArg0A != 0x00)
		*ptrArg0A.u1 = 0x00;
	if (ptrArg0E != 0x00)
		*ptrArg0E.u1 = 0x00;
	if (ptrArg12 != 0x00)
		*ptrArg12.u1 = 0x00;
	byte * ptrLoc06_n = (byte *) (fp - 90);
	while (true)
	{
		word16 wArg02_n = (word16) ptrArg02;
		word16 wArg04_n = SLICE(ptrArg02, word16, 16);
		if (*ptrArg02.u3 != 0x20)
			break;
		Eq_n ptrArg02_n = SEQ(wArg04_n, wArg02_n + 0x01);
		ptrArg02 = ptrArg02_n;
	}
	Eq_n ax_n = fn0800_BFC7(ptrArg02, out cx_n);
	Eq_n si_n = ax_n;
	if (ax_n > 0x50)
		si_n.u0 = 0x50;
	*ptrLoc06_n = 0x00;
	fn0800_C01E(fp - 0x59, ptrArg02, si_n);
	int8 Eq_n::* v26_n = fp - 0x59 + si_n;
	struct Eq_n * ss;
	ss->*v26_n = 0x00;
	int8 Eq_n::* wLoc06_n = v26_n;
	while (true)
	{
		int8 Eq_n::* v27_n = wLoc06_n - 0x01;
		wLoc06_n = v27_n;
		int16 ax_n = (int16) (ss->*v27_n);
		word16 cx_n;
		struct Eq_n seg0800_t::* bx_n = &seg0800_t::tBE1F;
		for (cx_n = 0x07; cx_n != 0x00; --cx_n)
		{
			if ((0x0800->*bx_n).w0000 == ax_n)
			{
				bx_n[7]();
				word16 bx_n;
				return bx_n;
			}
			++bx_n;
		}
	}
}

Eq_n g_tBE1F = // 0800:BE1F
	{
		0x00,
		
		{
			48471
		},
	};
// 0800:BE3B: Register word16 fn0800_BE3B(Stack Eq_n dwArg02, Stack Eq_n dwArg06, Stack Eq_n dwArg0A, Stack Eq_n dwArg0E, Stack Eq_n dwArg12)
// Called from:
//      fn0800-3509
//      fn0800-35A3
word16 fn0800_BE3B(Eq_n dwArg02, Eq_n dwArg06, Eq_n dwArg0A, Eq_n dwArg0E, Eq_n dwArg12)
{
	return fn0800_BC49(dwArg02, dwArg06, dwArg0A, dwArg0E, dwArg12);
}

// 0800:BEA2: Register word16 fn0800_BEA2(Register Eq_n cx, Register Eq_n dx, Register Eq_n ds, Stack Eq_n ptrArg02, Stack Eq_n dwArg06, Register out (memptr Eq_n byte) diOut)
// Called from:
//      fn0800-0541
//      fn0800-31B4
//      fn0800-37BE
word16 fn0800_BEA2(Eq_n cx, Eq_n dx, Eq_n ds, Eq_n ptrArg02, Eq_n dwArg06, byte & diOut)
{
	byte Eq_n::* di_n;
	mp16 fp;
	*ptrArg02.u3 = (char) 0x00;
	word16 si_n = fn0800-9828(cx, dx, (word16) ptrArg02, ds, fp + 0x0A, dwArg06, out di_n);
	diOut = di_n;
	return si_n;
}

<anonymous> g_tBEE5 = <code>; // 0800:BEE5
<anonymous> g_tBF0D = <code>; // 0800:BF0D
// 0800:BF18: Register Eq_n fn0800_BF18(Register Eq_n di, Register Eq_n ds, Stack (memptr Eq_n Eq_n) wArg06, Stack Eq_n wArg08)
// Called from:
//      fn0800-0541
Eq_n fn0800_BF18(Eq_n di, Eq_n ds, struct Eq_n Eq_n::* wArg06, Eq_n wArg08)
{
	mp16 fp;
	selector ss;
	return fn0800-8F97(di, ds, &seg0800_t::tBEE5, &seg0800_t::tBF0D, fp + 2, ss, wArg06, wArg08);
}

// 0800:BF5F: void fn0800_BF5F(Stack Eq_n ptrArg02, Stack segptr32 ptrArg06)
// Called from:
//      fn0800-8E6A
void fn0800_BF5F(Eq_n ptrArg02, segptr32 ptrArg06)
{
	byte Eq_n::* di_n = (word16) ptrArg02;
	struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (es_n->*di_n != 0x00)
			break;
	}
	byte Eq_n::* si_n = di_n - 1;
	struct Eq_n * es_n = SLICE(ptrArg06, selector, 16);
	byte Eq_n::* di_n = (word16) ptrArg06;
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		++di_n;
		--cx_n;
		if (es_n->*di_n != 0x00)
			break;
	}
	cu16 cx_n = ~cx_n;
	Eq_n di_n = di_n - cx_n;
	byte Eq_n::* di_n = si_n;
	<unknown>* si_n = di_n;
	if ((di_n & 0x01) != 0x00)
	{
		es_n->*si_n = (byte) (es_n->*di_n);
		si_n = (<unknown>*) ((word16) di_n + 1);
		di_n = si_n + 1;
		--cx_n;
	}
	uint16 cx_n = cx_n >> 0x01;
	memcpy(&(es_n->*di_n), si_n, cx_n *32 0x02);
	byte Eq_n::* si_n = (byte Eq_n::*) ((char *) si_n + cx_n * 0x02);
	byte Eq_n::* di_n = di_n + cx_n * 0x02;
	if (cx_n < 0x00)
		es_n->*di_n = es_n->*si_n;
}

// 0800:BF9E: void fn0800_BF9E(Stack Eq_n ptrArg02, Stack Eq_n ptrArg06)
// Called from:
//      fn0800-0402
//      fn0800-2DE2
//      fn0800_BB98
//      fn0800_C379
void fn0800_BF9E(Eq_n ptrArg02, Eq_n ptrArg06)
{
	byte Eq_n::* di_n = (word16) ptrArg06;
	struct Eq_n * es_n = SLICE(ptrArg06, selector, 16);
	word16 cx_n = ~0x00;
	while (cx_n != 0x00)
	{
		byte Eq_n::* di_n;
		di_n = di_n + 1;
		--cx_n;
		di_n = di_n;
		if (es_n->*di_n != 0x00)
			break;
	}
	memcpy(ptrArg02, ptrArg06, (uint32) ~cx_n);
}

// 0800:BFC7: Register word16 fn0800_BFC7(Stack Eq_n ptrArg02, Register out cui16 cxOut)
// Called from:
//      fn0800-0402
//      fn0800-0541
//      fn0800-9CE6
//      fn0800_BB98
//      fn0800_BC49
//      fn0800_C379
word16 fn0800_BFC7(Eq_n ptrArg02, cui16 & cxOut)
{
	word16 wArg04_n = SLICE(ptrArg02, word16, 16);
	byte Eq_n::* di_n = (word16) ptrArg02;
	struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
	word16 ax_n = 0x00;
	cui16 cx;
	if (wArg04_n != 0x00 || di_n != &Eq_n::b0000)
	{
		word16 cx_n = ~0x00;
		while (cx_n != 0x00)
		{
			byte Eq_n::* di_n;
			di_n = di_n + 1;
			--cx_n;
			di_n = di_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		cx = 0x00;
		ax_n = -cx_n;
	}
	cxOut = cx;
	return ax_n;
}

// 0800:BFE6: Register uint16 fn0800_BFE6(Stack (ptr32 Eq_n) ptrArg02, Stack (ptr32 Eq_n) ptrArg06, Stack uint16 wArg0A)
// Called from:
//      fn0800-29C5
uint16 fn0800_BFE6(<unknown> * ptrArg02, <unknown>* ptrArg06, uint16 wArg0A)
{
	byte Eq_n::* di_n = (word16) ptrArg06;
	struct Eq_n * es_n = SLICE(ptrArg06, selector, 16);
	uint16 ax_n = wArg0A;
	uint16 cx_n = wArg0A;
	if (wArg0A != 0x00)
	{
		byte Eq_n::* di_n = di_n;
		while (cx_n != 0x00)
		{
			byte Eq_n::* di_n;
			di_n = di_n + 1;
			--cx_n;
			di_n = di_n;
			if (es_n->*di_n != 0x00)
				break;
		}
		memcmp(ptrArg02, ptrArg06, (uint32) (wArg0A - cx_n));
		int16 firstDifference_n = __find_first_difference__(ptrArg02, ptrArg06);
		ax_n = (uint16) (((char *) (word16) ptrArg02 + firstDifference_n)[-1] - (di_n + firstDifference_n)[-1]);
	}
	return ax_n;
}

// 0800:C01E: void fn0800_C01E(Stack Eq_n ptrArg02, Stack Eq_n ptrArg06, Stack Eq_n wArg0A)
// Called from:
//      fn0800_BB98
//      fn0800_BC49
//      fn0800_C379
void fn0800_C01E(Eq_n ptrArg02, Eq_n ptrArg06, Eq_n wArg0A)
{
	byte Eq_n::* di_n = (word16) ptrArg06;
	struct Eq_n * es_n = SLICE(ptrArg06, selector, 16);
	Eq_n cx_n = wArg0A;
	while (cx_n != 0x00)
	{
		byte Eq_n::* di_n;
		di_n = di_n + 1;
		--cx_n;
		di_n = di_n;
		if (es_n->*di_n != 0x00)
			break;
	}
	word16 bx_n = wArg0A - cx_n;
	memcpy(ptrArg02, ptrArg06, (uint32) bx_n);
	struct Eq_n * es_n = SLICE(ptrArg02, selector, 16);
	byte Eq_n::* di_n = (word16) ptrArg02 + bx_n;
	Eq_n cx_n;
	for (cx_n = cx_n; cx_n != 0x00; --cx_n)
	{
		es_n->*di_n = 0x00;
		++di_n;
	}
}

// 0800:C04F: Register word16 fn0800_C04F(Register Eq_n ds, Stack (ptr32 Eq_n) ptrArg02, Stack (ptr32 Eq_n) ptrArg06, Register out word16 cxOut, Register out word16 dxOut)
// Called from:
//      fn0800-9764
word16 fn0800_C04F(Eq_n ds, struct Eq_n * ptrArg02, struct Eq_n * ptrArg06, word16 & cxOut, word16 & dxOut)
{
	byte ch_n;
	byte ch_n;
	byte ch_n;
	byte ch_n;
	fn0800_C379(ds);
	word16 dx_n = Mem13[ds:0x26E2:word16];
	ci16 si_n = ptrArg02->w0000;
	ui32 v23_v22_n = SEQ(SLICE(SEQ(Mem13[ds:9956:word16], dx_n) + 315532800, word16, 16), dx_n + 0xA600) + fn0800-8F18(0x1F80, 0x00, 0x0786, si_n + 63556 >> 0x02, out ch_n) + fn0800-8F18(0x3380, 0x00, 0x01E1, si_n + 63556 & 0x03, out ch_n);
	ui32 dwLoc06_n = v23_v22_n;
	if ((si_n + 63556 & 0x03) != 0x00)
		dwLoc06_n = v23_v22_n + 0x00015180;
	word16 cx_n = 0x00;
	Eq_n si_n = (int16) ptrArg02->b0003 - 0x01;
	while (si_n > 0x00)
	{
		--si_n;
		cx_n += (int16) (ds->*((word16) si_n + 9908));
	}
	Eq_n cx_n = cx_n + ((int16) ptrArg02->b0002 - 0x01);
	if (ptrArg02->b0003 > 0x02 && (ptrArg02->w0000 & 0x03) == 0x00)
		cx_n.u3 = &cx_n.u5->b0001;
	Eq_n ax_n = cx_n *s16 0x18 + (uint16) (ptrArg06->t0001).u0;
	Eq_n si_n = ax_n;
	if (Mem171[ds:0x26E6:word16] != 0x00 && fn0800_C553(ds, ptrArg02->w0000 + 63566, 0x00, cx_n, (ptrArg06->t0001).u0) != 0x00)
		si_n = ax_n - 0x01;
	ui32 v32_v31_n = dwLoc06_n + fn0800-8F18(0x0E10, 0x00, 0x00, si_n, out ch_n);
	ui32 bx_cx_n = fn0800-8F18(0x3C, 0x00, 0x00, (uint16) ptrArg06->b0000, out ch_n) + (uint32) ptrArg06->b0003;
	cxOut = (word16) bx_cx_n;
	ui32 v36_v35_n = v32_v31_n + bx_cx_n;
	dxOut = SLICE(v36_v35_n, word16, 16);
	return (word16) v36_v35_n;
}

// 0800:C177: void fn0800_C177(Register Eq_n ds, Stack ui32 dwArg02, Stack (ptr32 Eq_n) ptrArg06, Stack (ptr32 Eq_n) ptrArg0A)
void fn0800_C177(Eq_n ds, ui32 dwArg02, struct Eq_n * ptrArg06, struct Eq_n * ptrArg0A)
{
	ui32 dwArg02_n;
	ui32 dwArg02_n;
	word16 cx_n;
	word16 sp_n;
	ui32 dwArg02_n;
	word16 wLoc44;
	mp16 fp;
	word16 wLoc34;
	word16 cx_n;
	word16 wLoc24;
	word16 cx_n;
	word16 wLoc14;
	fn0800_C379(ds);
	ui32 v12_v11_n = dwArg02 - (Mem7[ds:0x26E2:ui32] + 315532800);
	ptrArg0A->b0002 = 0x00;
	word16 v12_n = SLICE(v12_v11_n, word16, 16);
	word16 v11_n = (word16) v12_v11_n;
	word16 wLoc0C;
	ptrArg0A->b0003 = (byte) fn0800-8BCA(SEQ(v11_n, wLoc0C), SEQ(0x3C, v12_n));
	int32 dx_ax_n = fn0800-8BBB(SEQ(v11_n, wLoc14), SEQ(0x3C, v12_n), out cx_n);
	word16 dx_n = SLICE(dx_ax_n, word16, 16);
	word16 ax_n = (word16) dx_ax_n;
	word16 wLoc1C;
	ptrArg0A->b0000 = (byte) fn0800-8BCA(SEQ(ax_n, wLoc1C), SEQ(0x3C, dx_n));
	int32 dx_ax_n = fn0800-8BBB(SEQ(ax_n, wLoc24), SEQ(0x3C, dx_n), out cx_n);
	word16 dx_n = SLICE(dx_ax_n, word16, 16);
	word16 ax_n = (word16) dx_ax_n;
	word16 wLoc2C;
	word16 cx_n;
	ptrArg06->w0000 = ((word16) fn0800-8BBB(SEQ(ax_n, wLoc2C), SEQ(0x88F8, dx_n), out cx_n) << 0x02) + 0x07BC;
	Eq_n dx_ax_n = fn0800-8BCA(SEQ(ax_n, wLoc34), SEQ(0x88F8, dx_n));
	mp16 sp_n = fp - 50;
	word16 ax_n = (word16) dx_ax_n;
	Eq_n dwArg02_n = dx_ax_n;
	if (dx_ax_n >= 0x2250)
	{
		++ptrArg06->w0000;
		word16 v34_n = SLICE(dx_ax_n - 0x2250, word16, 16);
		word16 wLoc3C;
		word16 cx_n;
		ptrArg06->w0000 += (word16) fn0800-8BBB(SEQ(ax_n - 0x2250, wLoc3C), SEQ(0x2238, v34_n), out cx_n);
		mp16 sp_n = fp - 66;
		Eq_n dwArg02_n = fn0800-8BCA(SEQ(ax_n - 0x2250, wLoc44), SEQ(0x2238, v34_n));
	}
	Eq_n wArg02_n = (word16) dwArg02_n;
	Eq_n wArg04_n;
	wArg04_n.u3 = SLICE(dwArg02_n, word16, 16);
	if (Mem281[ds:0x26E6:word16] != 0x00)
	{
		struct Eq_n Eq_n::* sp_n = sp_n - 2;
		selector ss;
		(ss->*sp_n).w0000 = 0x00;
		(ss->*sp_n).wFFFFFFFE = 0x18;
		(ss->*sp_n).tFFFFFFFC.u2 = (uint16) wArg04_n;
		(ss->*sp_n).tFFFFFFFA.u1 = (word16) wArg02_n;
		(ss->*sp_n).tFFFFFFF8.u2 = (uint16) (word16) fn0800-8BCA((ss->*sp_n).tFFFFFFF8.u3, (ss->*sp_n).tFFFFFFFC.u3);
		(ss->*sp_n).wFFFFFFF6 = 0x00;
		(ss->*sp_n).wFFFFFFF4 = 0x18;
		(ss->*sp_n).tFFFFFFF2.u2 = (uint16) wArg04_n;
		(ss->*sp_n).tFFFFFFF0.u1 = (word16) wArg02_n;
		word16 cx_n;
		(ss->*sp_n).tFFFFFFEE.u2 = (uint16) (word16) fn0800-8BBB((ss->*sp_n).tFFFFFFEE.u3, (ss->*sp_n).tFFFFFFF2.u3, out cx_n);
		(ss->*sp_n).wFFFFFFEC = 0x00;
		(ss->*sp_n).tFFFFFFEA.u0 = (int16) (ptrArg06->w0000 + 63566);
		if (fn0800_C553(ds, (ss->*sp_n).tFFFFFFEA.u0, (ss->*sp_n).wFFFFFFEC, (ss->*sp_n).tFFFFFFEE.u2, (ss->*sp_n).tFFFFFFF0.u0) != 0x00)
		{
			word16 wArg02_n = (word16) wArg02_n.u1 + 1;
			word16 wArg04_n = SLICE(dwArg02_n + 0x01, word16, 16);
		}
	}
	word16 wArg02_n;
	int16 v53_n;
	word16 wArg04_n;
	ptrArg0A->b0001 = (byte) fn0800-8BCA(SEQ(wArg02_n, v53_n), SEQ(0x18, wArg04_n));
	int32 dx_ax_n = fn0800-8BBB(SEQ(wArg02_n, 0x00), SEQ(0x18, wArg04_n), out cx_n);
	cup16 ax_n = (word16) dx_ax_n;
	v53_n = SLICE(dx_ax_n + 0x01, word16, 16);
	ui32 dwArg02_n = SEQ(v53_n, ax_n + 0x01);
	if ((ptrArg06->w0000 & 0x03) == 0x00)
	{
		if (v53_n >= 0x00 && (v53_n > 0x00 || ax_n > 0x3B))
		{
			int32 dwArg02_n = dx_ax_n;
		}
		else
		{
			int32 dwArg02_n = SEQ(v53_n, ax_n + 0x01);
			if (v53_n == 0x00)
			{
				int32 dwArg02_n = SEQ(v53_n, ax_n + 0x01);
				if (ax_n == 0x3B)
				{
					ptrArg06->b0003 = 0x02;
					ptrArg06->b0002 = 0x1D;
					return;
				}
			}
		}
	}
	ptrArg06->b0003 = 0x00;
	ui32 dwArg02_n = dwArg02_n;
	byte bArg02_n;
	while (true)
	{
		Eq_n wArg02_n = (word16) dwArg02_n;
		bArg02_n = (byte) wArg02_n;
		ci16 wArg04_n = SLICE(dwArg02_n, word16, 16);
		Eq_n ax_n = CONVERT(Mem479[ds:CONVERT(Mem479[ptrArg06 + 3:byte], int8, int16) + 9908:byte], int8, int16);
		if (wArg04_n <= 0x00 && (wArg04_n != 0x00 || ax_n >= wArg02_n))
			break;
		ui32 v61_v60_n = dwArg02_n - CONVERT(Mem479[ds:CONVERT(Mem479[ptrArg06 + 3:byte], int8, int16) + 9908:byte], int8, uint32);
		++ptrArg06->b0003;
		ui32 dwArg02_n = v61_v60_n;
	}
	++ptrArg06->b0003;
	ptrArg06->b0002 = bArg02_n;
}

// 0800:C379: void fn0800_C379(Register Eq_n ds)
// Called from:
//      fn0800_C04F
//      fn0800_C177
void fn0800_C379(Eq_n ds)
{
	byte ch_n;
	uint16 dx_n;
	Eq_n dx_ax_n = fn0800_AFCB(ds, SEQ(ds, 9960));
	struct Eq_n * dx_n = SLICE(dx_ax_n, word16, 16);
	<unknown> Eq_n::* ax_n = (word16) dx_ax_n;
	word16 cx_n;
	if (dx_ax_n == 0x00 || (fn0800_BFC7(dx_ax_n, out cx_n) < 0x04 || ((CONVERT(Mem46[ds:CONVERT(Mem46[dx_ax_n + 0x00:byte], int8, int16) + 0x2251:byte], int8, int16) & 0x0C) == 0x00 || ((CONVERT(Mem46[ds:CONVERT(Mem46[dx_ax_n + 1:byte], int8, int16) + 0x2251:byte], int8, int16) & 0x0C) == 0x00 || ((CONVERT(Mem46[ds:CONVERT(Mem46[dx_ax_n + 2:byte], int8, int16) + 0x2251:byte], int8, int16) & 0x0C) == 0x00 || (dx_ax_n.u5)->b0003 != 0x2D && ((dx_ax_n.u5)->b0003 != 0x2B && (Mem46[ds:CONVERT(Mem46[dx_ax_n + 3:byte], int8, int16) + 0x2251:byte] & 0x02) == 0x00))))) || (CONVERT(Mem46[ds:CONVERT(Mem46[dx_ax_n + 3:byte], int8, int16) + 0x2251:byte], int8, int16) & 0x02) == 0x00 && (CONVERT(Mem46[ds:CONVERT(Mem46[dx_ax_n + 4:byte], int8, int16) + 0x2251:byte], int8, int16) & 0x02) == 0x00)
	{
		Mem342[ds:0x26E6:word16] = 0x01;
		Mem343[ds:9956:word16] = 0x00;
		Mem344[ds:0x26E2:word16] = 18000;
		fn0800_BF9E(Mem351[ds:9946:word32], SEQ(ds, 9963));
		fn0800_BF9E(Mem373[ds:9950:word32], SEQ(ds, 9967));
	}
	else
	{
		fn0800_B083(Mem142[ds:9950:word32], 0x00, 0x04);
		fn0800_C01E(Mem171[ds:9946:word32], dx_ax_n, 0x03);
		Mem192[Mem177[ds:9946:segptr32] + 3:byte] = 0x00;
		ui32 dx_ax_n = fn0800-8F18(0x0E10, dx_n, 0x00, fn0800_A471(ds, &(dx_n->*((char *) ax_n + 3)), out dx_n), out ch_n);
		Mem236[ds:9956:word16] = SLICE(dx_ax_n, word16, 16);
		Mem237[ds:0x26E2:word16] = SLICE(dx_ax_n, word16, 0);
		Mem238[ds:0x26E6:word16] = 0x00;
		Eq_n si_n;
		si_n.u0 = 0x03;
		while (*(dx_ax_n + si_n) != 0x00)
		{
			if ((Mem238[ds:CONVERT(Mem238[dx_ax_n + si_n:byte], int8, int16) + 0x2251:byte] & 0x0C) != 0x00)
			{
				word16 cx_n;
				if (fn0800_BFC7(ax_n + si_n, out cx_n) >= 0x03 && ((CONVERT(Mem270[ds:CONVERT(Mem270[dx_n:(ax_n + 1) + si_n:byte], int8, int16) + 0x2251:byte], int8, int16) & 0x0C) != 0x00 && (CONVERT(Mem270[ds:CONVERT(Mem270[dx_n:(ax_n + 2) + si_n:byte], int8, int16) + 0x2251:byte], int8, int16) & 0x0C) != 0x00))
				{
					fn0800_C01E(Mem317[ds:9950:word32], SEQ(dx_n, ax_n + si_n), 0x03);
					Mem339[Mem323[ds:9950:segptr32] + 3:byte] = 0x00;
					Mem340[ds:0x26E6:word16] = 0x01;
				}
				return;
			}
			si_n = (word32) si_n + 1;
		}
	}
}

// 0800:C553: Register word16 fn0800_C553(Register Eq_n ds, Stack Eq_n wArg02, Stack uint16 wArg04, Stack Eq_n wArg06, Stack Eq_n bArg08)
// Called from:
//      fn0800_C04F
//      fn0800_C177
word16 fn0800_C553(Eq_n ds, Eq_n wArg02, uint16 wArg04, Eq_n wArg06, Eq_n bArg08)
{
	if (wArg04 == 0x00)
	{
		Eq_n si_n = wArg06;
		if (wArg06 >= 0x3B && ((word16) wArg02 + 70 & 0x03) == 0x00)
			si_n = wArg06 - 0x01;
		wArg04 = 0x00;
		while ((*((word32) ds + 9920))[wArg04].t0000.u2 <= si_n)
			++wArg04;
	}
	else
	{
		if (wArg04 < 0x03 || ((word16) wArg02 + 70 & 0x03) != 0x00)
			--wArg06;
		wArg06.u3 += (*((word32) ds + 9920))[wArg04 - 0x01];
	}
	word16 ax_n;
	if (wArg04 < 0x04)
	{
l0800_C62B:
		ax_n = 0x00;
		return ax_n;
	}
	if (wArg04 != 0x04)
	{
		if (wArg04 > 0x0A)
			goto l0800_C62B;
		if (wArg04 != 0x0A)
			goto l0800_C626;
	}
	word16 cx_n;
	if (wArg02 > 0x10 && wArg04 == 0x04)
		cx_n = (*((word32) ds + 9918))[wArg04] + 0x07;
	else
		cx_n = (*((word32) ds + 9920))[wArg04];
	if (((byte) wArg02 + 0xB2 & 0x03) != 0x00)
		--cx_n;
	Eq_n cx_n = cx_n - (uint32) ((wArg02 * 0x016D + (((word16) wArg02 + 1 >> 0x02) + cx_n)) + 0x04) % 0x07;
	if (wArg04 == 0x04)
	{
		if (wArg06 <= cx_n && (wArg06 != cx_n || bArg08 < 0x02))
			goto l0800_C62B;
	}
	else if (wArg06 >= cx_n && (wArg06 != cx_n || bArg08 > 0x01))
		goto l0800_C62B;
l0800_C626:
	ax_n = 0x01;
	return ax_n;
}

// 0800:C632: Register Eq_n fn0800_C632(Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n dwArg04, Stack Eq_n wArg08, Register out Eq_n dxOut, Register out ui16 bxOut)
// Called from:
//      fn0800_A6B7
//      fn0800_B4BE
Eq_n fn0800_C632(Eq_n ds, Eq_n wArg02, Eq_n dwArg04, Eq_n wArg08, union Eq_n & dxOut, ui16 & bxOut)
{
	word16 dx_n;
	word16 cx_n;
	<unknown> Eq_n::* fp;
	Eq_n ax_n;
	Eq_n dx;
	ui16 bx;
	if (wArg02 >=u Mem15[ds:9448:word16])
		ax_n = fn0800-8D2B(ds, 0x06);
	else if (wArg08 < 0x01)
		ax_n.u0 = 0x00;
	else
	{
		if (((*((word32) ds + 9450))[wArg02] & 0x0800) != 0x00)
		{
			word16 cx_n;
			word16 dx_n;
			fn0800-8E29(ds, wArg02, 0x00, 0x02, out cx_n, out dx_n);
		}
		if (((*((word32) ds + 9450))[wArg02] & 0x4000) == 0x00)
		{
			word16 cx_n;
			ax_n = fn0800_C779(ds, wArg02, dwArg04, wArg08, out cx_n, out dx, out bx);
		}
		else
		{
			(*((word32) ds + 9450))[wArg02] &= ~0x0200;
			bx = wArg02 << 0x01;
			Eq_n wLoc08_n = wArg08;
			Eq_n ptrLoc0E_n = dwArg04;
			Eq_n si_n;
			Eq_n ax_n;
			Eq_n v24_n;
			Eq_n ax_n;
			do
			{
				int8 * ptrLoc06_n = (int8 *) (fp - 0x90);
				word16 wLoc06_n;
				cup16 dx_n;
				do
				{
					word16 wLoc04_n = SLICE(ptrLoc06_n, word16, 16);
					word16 wLoc0E_n = (word16) ptrLoc0E_n;
					word16 wLoc0C_n = SLICE(ptrLoc0E_n, word16, 16);
					word16 wLoc06_n = (word16) ptrLoc06_n;
					int8 * ptrLoc06_n = ptrLoc06_n;
					if (wLoc08_n == 0x00)
					{
						si_n = wLoc06_n - (fp - 0x90);
						dx.u0 = 0x00;
						if (si_n > 0x00)
						{
							Eq_n ax_n = fn0800_C779(ds, wArg02, fp - 0x90, si_n, out cx_n, out dx_n, out bx);
							dx = ax_n;
							if (ax_n != si_n)
							{
								if (ax_n == ~0x00)
									goto l0800_C71A;
								ax_n = wArg08;
								goto l0800_C76A;
							}
						}
						ax_n = wArg08;
						goto l0800_C773;
					}
					v24_n = wLoc08_n - 0x01;
					wLoc08_n = v24_n;
					int8 al_n = (int8) *ptrLoc0E_n.u3;
					ptrLoc0E_n = SEQ(wLoc0C_n, wLoc0E_n + 0x01);
					if (al_n == 0x0A)
					{
						*ptrLoc06_n = 0x0D;
						ptrLoc06_n = SEQ(wLoc04_n, wLoc06_n + 0x01);
					}
					*ptrLoc06_n = al_n;
					wLoc06_n = (word16) ptrLoc06_n;
					word16 wLoc04_n = SLICE(ptrLoc06_n, word16, 16);
					dx_n = wLoc06_n + 0x01 - (fp - 0x90);
					bx = 0x00;
					ptrLoc06_n = SEQ(wLoc04_n, wLoc06_n + 0x01);
					if (false)
						continue;
					if (false)
						break;
					ptrLoc06_n = SEQ(wLoc04_n, wLoc06_n + 0x01);
				} while (dx_n < 0x80);
				si_n = wLoc06_n + 0x01 - (fp - 0x90);
				word16 cx_n;
				word16 dx_n;
				ax_n = fn0800_C779(ds, wArg02, fp - 0x90, si_n, out cx_n, out dx_n, out bx);
				dx = ax_n;
			} while (ax_n == si_n);
			if (ax_n == ~0x00)
			{
l0800_C71A:
				ax_n.u0 = ~0x00;
			}
			else
			{
				ax_n = wArg08 - v24_n;
l0800_C76A:
				ax_n = ax_n + dx - si_n;
			}
		}
	}
l0800_C773:
	dxOut = dx;
	bxOut = bx;
	return ax_n;
}

// 0800:C779: Register Eq_n fn0800_C779(Register Eq_n ds, Stack Eq_n wArg02, Stack Eq_n ptrArg04, Stack Eq_n wArg08, Register out Eq_n cxOut, Register out word16 dxOut, Register out Eq_n bxOut)
// Called from:
//      fn0800_B324
//      fn0800_B4BE
//      fn0800_C632
Eq_n fn0800_C779(Eq_n ds, Eq_n wArg02, Eq_n ptrArg04, Eq_n wArg08, union Eq_n & cxOut, word16 & dxOut, union Eq_n & bxOut)
{
	Eq_n bx_n = wArg02 << 0x01;
	Eq_n wLoc04_n;
	Eq_n ax_n;
	if (((*((word32) ds + 9450))[wArg02] & 0x01) != 0x00)
		wLoc04_n.u0 = 0x05;
	else
	{
		bx_n = wArg02;
		Eq_n cx = wArg08;
		word16 dx = (word16) ptrArg04;
		Eq_n ax_n;
		if (!msdos_write_file(wArg02, wArg08, ptrArg04, out ax_n))
		{
			(*((word32) ds + 9450))[wArg02] |= 0x1000;
			bx_n = wArg02 << 0x01;
			ax_n = ax_n;
l0800_C7B3:
			cxOut = cx;
			dxOut = dx;
			bxOut = bx_n;
			return ax_n;
		}
		wLoc04_n = ax_n;
	}
	ax_n = fn0800-8D2B(ds, wLoc04_n);
	goto l0800_C7B3;
}

