// File: FreeSlave[P]vhlt/hlbsp/brink.cpp
// Function: AnalyzeBrinks(bbrinkinfo_s*)
void AnalyzeBrinks (bbrinkinfo_t *info)
{
	int countgood = 0;
	int countinvalid = 0;
	int countskipped = 0;
	int countfixed = 0;
	int i, j, side;
	for (i = 0; i < info->numbrinks; i++)
	{
		bbrink_t *b = info->brinks[i];
		if (b->numnodes <= 5) // quickly reject the most trivial brinks
		{
#ifdef HLBSP_BRINKNOTUSEDBYLEAF_FIX
			if (b->numnodes != 3 && b->numnodes != 5)
			{
				PrintOnce ("AnalyzeBrinks: internal error 1");
				hlassume (false, assume_first);
			}
			// because a brink won't necessarily be split twice after its creation
			if (b->numnodes == 3)
			{
				if (g_developer >= DEVELOPER_LEVEL_FLUFF)
				{
					Developer (DEVELOPER_LEVEL_FLUFF, "Brink wasn't split by the second plane:\n");
					PrintBrink (b);
				}
				countinvalid++;
			}
			else
			{
				countgood++;
			}
			continue;
#else
			hlassume (b->numnodes == 5, assume_first);
			countgood++;
			continue;
#endif
		}
		
		if (b->numnodes > 2 * MAXBRINKWEDGES - 1)
		{
			if (g_developer >= DEVELOPER_LEVEL_MEGASPAM)
			{
				Developer (DEVELOPER_LEVEL_MEGASPAM, "Skipping complicated brink:\n");
				PrintBrink (b);
			}
			countskipped++;
			continue;
		}
		bcircle_t c;
		// build the circle to find out the planes a player may move along
		if (!CalculateCircle (b, &c))
		{
			if (g_developer >= DEVELOPER_LEVEL_FLUFF)
			{
				Developer (DEVELOPER_LEVEL_FLUFF, "CalculateCircle failed for brink:\n");
				PrintBrink (b);
			}
			countinvalid++;
			continue;
		}
		
		int transitionfound[2];
		bsurface_t *transitionpos[2];
		bool transitionside[2];
		for (side = 0; side < 2; side++)
		{
			transitionfound[side] = 0;
			for (j = 1; j < c.numwedges[side]; j++) // we will later consider the surfaces on the first split
			{
				bsurface_t *s = &c.surfaces[side][j];
				if ((s->prev->content == CONTENTS_SOLID) != (s->next->content == CONTENTS_SOLID))
				{
					transitionfound[side]++;
					transitionpos[side] = s;
					transitionside[side] = (s->prev->content == CONTENTS_SOLID);
				}
			}
		}

		if (transitionfound[0] == 0 || transitionfound[1] == 0)
		{
			// at least one side of the first split is completely SOLID or EMPTY. no bugs in this case
			countgood++;
			continue;
		}

		if (transitionfound[0] > 1 || transitionfound[1] > 1 ||
			(c.surfaces[0][0].prev->content == CONTENTS_SOLID) != (c.surfaces[0][0].next->content == CONTENTS_SOLID) ||
			(c.surfaces[1][0].prev->content == CONTENTS_SOLID) != (c.surfaces[1][0].next->content == CONTENTS_SOLID))
		{
			// there must at least 3 transition surfaces now, which is too complicated. just leave it unfixed
			if (g_developer >= DEVELOPER_LEVEL_MEGASPAM)
			{
				Developer (DEVELOPER_LEVEL_MEGASPAM, "Skipping complicated brink:\n");
				PrintBrink (b);
				PrintCircle (&c);
			}
			countskipped++;
			continue;
		}
		
		if (transitionside[1] != !transitionside[0])
		{
			PrintOnce ("AnalyzeBrinks: internal error 2");
			hlassume (false, assume_first);
		}
		bool bfix = false;
		bool berror = false;
		vec3_t vup = {0, 0, 1};
		bool isfloor;
		bool onfloor;
		bool blocking;
		{
			isfloor = false;
			for (int side2 = 0; side2 < 2; side2++)
			{
				vec3_t normal;
				VectorScale (transitionpos[side2]->normal, transitionside[side2]? -1: 1, normal); // pointing from SOLID to EMPTY
				if (DotProduct (normal, vup) > BRINK_FLOOR_THRESHOLD)
				{
					isfloor = true;
				}
			}
		}
		{
			onfloor = false;
			for (int side2 = 0; side2 < 2; side2++)
			{
				btreepoint_t *tp = GetPointFromEdge (b->edge, side2);
#ifdef HLBSP_BRINKHACK_BUGFIX
				if (tp->infinite)
				{
					continue;
				}
#endif
				for (btreeedge_l::iterator ei = tp->edges->begin (); ei != tp->edges->end (); ei++)
				{
					for (btreeface_l::iterator fi = ei->e->faces->begin (); fi != ei->e->faces->end (); fi++)
					{
#ifdef HLBSP_BRINKHACK_BUGFIX
						if (fi->f->infinite || GetLeafFromFace (fi->f, false)->infinite || GetLeafFromFace (fi->f, true)->infinite)
						{
							PrintOnce ("AnalyzeBrinks: internal error: an infinite object contains a finite object");
							hlassume (false, assume_first);
						}
#endif
						for (int side3 = 0; side3 < 2; side3++)
						{
							vec3_t normal;
							VectorScale (fi->f->plane->normal, (fi->f->planeside != (bool)side3)? -1: 1, normal);
							if (DotProduct (normal, vup) > BRINK_FLOOR_THRESHOLD
								&& GetLeafFromFace (fi->f, side3)->clipnode->content == CONTENTS_SOLID
								&& GetLeafFromFace (fi->f, !side3)->clipnode->content != CONTENTS_SOLID)
							{
								onfloor = true;
							}
						}
					}
				}
			}
		}
		// this code does not fix all the bugs, it only aims to fix most of the bugs
		for (side = 0; side < 2; side++)
		{
			bsurface_t *smovement = transitionpos[side];
			bsurface_t *s;
			for (s = transitionside[!side]? &c.surfaces[!side][0]: &c.surfaces[side][0]; ; s = transitionside[!side]? s->next->next: s->prev->prev)
			{
				bwedge_t *w = transitionside[!side]? s->next: s->prev;
				bsurface_t *snext = transitionside[!side]? w->next: w->prev;
				vec3_t tmp;
				vec_t dot;
				CrossProduct (smovement->normal, snext->normal, tmp);
				dot = DotProduct (tmp, c.axis);
				if (transitionside[!side]? dot < 0.01: dot > -0.01)
				{
					break;
				}
				if (w->content != CONTENTS_SOLID)
				{
					break;
				}
				if (snext == (transitionside[!side]? &c.surfaces[side][0]: &c.surfaces[!side][0]))
				{
					Developer (DEVELOPER_LEVEL_ERROR, "AnalyzeBrinks: surface past 0\n");
					break;
				}
				bfix = true;
				{
					if (DotProduct (smovement->normal, s->normal) > 0.01)
					{
						blocking = false;
					}
					else
					{
						blocking = true;
					}
				}
				bclipnode_t *clipnode = (*b->nodes)[w->nodenum].clipnode;
				int planenum = (*b->nodes)[smovement->nodenum].planenum;
				bool planeside = transitionside[!side]? smovement->nodeside: !smovement->nodeside;
				bbrinklevel_e brinktype;
				brinktype = isfloor? (blocking? BrinkFloorBlocking: BrinkFloor): onfloor? (blocking? BrinkWallBlocking: BrinkWall): BrinkAny;
				if (!AddPartition (clipnode, planenum, planeside, CONTENTS_EMPTY, brinktype))
				{
					berror = true;
				}
			}
		}
		if (berror)
		{
			if (g_developer >= DEVELOPER_LEVEL_FLUFF)
			{
				Developer (DEVELOPER_LEVEL_FLUFF, "AddPartition failed for brink:\n");
				PrintBrink (b);
			}
			countinvalid++;
		}
		else if (!bfix)
		{
			countgood++;
		}
		else
		{
			countfixed++;
		}
	}
	Developer (DEVELOPER_LEVEL_MESSAGE, "brinks: good = %d skipped = %d fixed = %d invalid = %d\n", countgood, countskipped, countfixed, countinvalid);
}

// Assembly:
subq $0x25f8, %rsp           # imm = 0x25F8
movq %rdi, 0x25f0(%rsp)
movl $0x0, 0x25ec(%rsp)
movl $0x0, 0x25e8(%rsp)
movl $0x0, 0x25e4(%rsp)
movl $0x0, 0x25e0(%rsp)
movl $0x0, 0x25dc(%rsp)
movl 0x25dc(%rsp), %eax
movq 0x25f0(%rsp), %rcx
cmpl 0x20(%rcx), %eax
jge 0x18c38
movq 0x25f0(%rsp), %rax
movq 0x28(%rax), %rax
movslq 0x25dc(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x25c8(%rsp)
movq 0x25c8(%rsp), %rax
cmpl $0x5, 0x48(%rax)
jg 0x17d36
movq 0x25c8(%rsp), %rax
cmpl $0x3, 0x48(%rax)
je 0x17cd3
movq 0x25c8(%rsp), %rax
cmpl $0x5, 0x48(%rax)
je 0x17cd3
leaq 0x220b9(%rip), %rdi     # 0x39d7c
movb $0x0, %al
callq 0xb840
xorl %esi, %esi
movl %esi, %edi
callq 0xbe90
movq 0x25c8(%rsp), %rax
cmpl $0x3, 0x48(%rax)
jne 0x17d20
leaq 0x20c5728(%rip), %rax   # 0x20dd410
cmpl $0x4, (%rax)
jl 0x17d0d
movl $0x4, %edi
leaq 0x220a3(%rip), %rsi     # 0x39d9c
movb $0x0, %al
callq 0xbb80
movq 0x25c8(%rsp), %rdi
callq 0x12200
movl 0x25e8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x25e8(%rsp)
jmp 0x17d31
movl 0x25ec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x25ec(%rsp)
jmp 0x18c22
movq 0x25c8(%rsp), %rax
cmpl $0x7f, 0x48(%rax)
jle 0x17d86
leaq 0x20c56c5(%rip), %rax   # 0x20dd410
cmpl $0x6, (%rax)
jl 0x17d70
movl $0x6, %edi
leaq 0x22069(%rip), %rsi     # 0x39dc5
movb $0x0, %al
callq 0xbb80
movq 0x25c8(%rsp), %rdi
callq 0x12200
movl 0x25e4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x25e4(%rsp)
jmp 0x18c22
movq 0x25c8(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x16a90
testb $0x1, %al
jne 0x17de1
leaq 0x20c566a(%rip), %rax   # 0x20dd410
cmpl $0x4, (%rax)
jl 0x17dcb
movl $0x4, %edi
leaq 0x2202b(%rip), %rsi     # 0x39de2
movb $0x0, %al
callq 0xbb80
movq 0x25c8(%rsp), %rdi
callq 0x12200
movl 0x25e8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x25e8(%rsp)
jmp 0x18c22
movl $0x0, 0x25d4(%rsp)
cmpl $0x2, 0x25d4(%rsp)
jge 0x17f23
movslq 0x25d4(%rsp), %rax
movl $0x0, 0x188(%rsp,%rax,4)
movl $0x1, 0x25d8(%rsp)
movl 0x25d8(%rsp), %eax
movslq 0x25d4(%rsp), %rcx
cmpl 0x1c0(%rsp,%rcx,4), %eax
jge 0x17f0b
leaq 0x190(%rsp), %rax
addq $0xc38, %rax            # imm = 0xC38
movslq 0x25d4(%rsp), %rcx
imulq $0xc00, %rcx, %rcx      # imm = 0xC00
addq %rcx, %rax
movslq 0x25d8(%rsp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x160(%rsp)
movq 0x160(%rsp), %rax
movq 0x20(%rax), %rax
cmpl $-0x2, (%rax)
sete %al
andb $0x1, %al
movzbl %al, %eax
movq 0x160(%rsp), %rcx
movq 0x28(%rcx), %rcx
cmpl $-0x2, (%rcx)
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0x17ef3
movslq 0x25d4(%rsp), %rax
movl 0x188(%rsp,%rax,4), %ecx
addl $0x1, %ecx
movl %ecx, 0x188(%rsp,%rax,4)
movq 0x160(%rsp), %rcx
movslq 0x25d4(%rsp), %rax
movq %rcx, 0x170(%rsp,%rax,8)
movq 0x160(%rsp), %rax
movq 0x20(%rax), %rax
cmpl $-0x2, (%rax)
sete %cl
movslq 0x25d4(%rsp), %rax
andb $0x1, %cl
movb %cl, 0x16e(%rsp,%rax)
jmp 0x17ef5
movl 0x25d8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x25d8(%rsp)
jmp 0x17e18
jmp 0x17f0d
movl 0x25d4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x25d4(%rsp)
jmp 0x17dec
cmpl $0x0, 0x188(%rsp)
je 0x17f37
cmpl $0x0, 0x18c(%rsp)
jne 0x17f4d
movl 0x25ec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x25ec(%rsp)
jmp 0x18c22
cmpl $0x1, 0x188(%rsp)
jg 0x17fb7
cmpl $0x1, 0x18c(%rsp)
jg 0x17fb7
movq 0xde8(%rsp), %rax
cmpl $-0x2, (%rax)
sete %al
andb $0x1, %al
movzbl %al, %eax
movq 0xdf0(%rsp), %rcx
cmpl $-0x2, (%rcx)
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x17fb7
movq 0x19e8(%rsp), %rax
cmpl $-0x2, (%rax)
sete %al
andb $0x1, %al
movzbl %al, %eax
movq 0x19f0(%rsp), %rcx
cmpl $-0x2, (%rcx)
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0x18006
leaq 0x20c5452(%rip), %rax   # 0x20dd410
cmpl $0x6, (%rax)
jl 0x17ff0
movl $0x6, %edi
leaq 0x21df6(%rip), %rsi     # 0x39dc5
movb $0x0, %al
callq 0xbb80
movq 0x25c8(%rsp), %rdi
callq 0x12200
leaq 0x190(%rsp), %rdi
callq 0x17780
movl 0x25e4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x25e4(%rsp)
jmp 0x18c22
movb 0x16f(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movb 0x16e(%rsp), %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0x1803d
leaq 0x21dd8(%rip), %rdi     # 0x39e05
movb $0x0, %al
callq 0xb840
xorl %esi, %esi
movl %esi, %edi
callq 0xbe90
movb $0x0, 0x15f(%rsp)
movb $0x0, 0x15e(%rsp)
movq 0x2160c(%rip), %rax     # 0x39660
movq %rax, 0x140(%rsp)
movq 0x21605(%rip), %rax     # 0x39668
movq %rax, 0x148(%rsp)
movq 0x215fe(%rip), %rax     # 0x39670
movq %rax, 0x150(%rsp)
movb $0x0, 0x13f(%rsp)
movl $0x0, 0x138(%rsp)
cmpl $0x2, 0x138(%rsp)
jge 0x181dd
movslq 0x138(%rsp), %rax
movq 0x170(%rsp,%rax,8), %rax
movsd (%rax), %xmm0
movslq 0x138(%rsp), %rax
movb 0x16e(%rsp,%rax), %dl
movl $0x1, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testb $0x1, %dl
cmovnel %ecx, %eax
cvtsi2sd %eax, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x120(%rsp)
movslq 0x138(%rsp), %rax
movq 0x170(%rsp,%rax,8), %rax
movsd 0x8(%rax), %xmm0
movslq 0x138(%rsp), %rax
movb 0x16e(%rsp,%rax), %dl
movl $0x1, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testb $0x1, %dl
cmovnel %ecx, %eax
cvtsi2sd %eax, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x128(%rsp)
movslq 0x138(%rsp), %rax
movq 0x170(%rsp,%rax,8), %rax
movsd 0x10(%rax), %xmm0
movslq 0x138(%rsp), %rax
movb 0x16e(%rsp,%rax), %dl
movl $0x1, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testb $0x1, %dl
cmovnel %ecx, %eax
cvtsi2sd %eax, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x130(%rsp)
movsd 0x120(%rsp), %xmm1
movsd 0x140(%rsp), %xmm2
movsd 0x128(%rsp), %xmm0
mulsd 0x148(%rsp), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x130(%rsp), %xmm0
movsd 0x150(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x21479(%rip), %xmm1    # 0x39630
ucomisd %xmm1, %xmm0
jbe 0x181c5
movb $0x1, 0x13f(%rsp)
jmp 0x181c7
movl 0x138(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x138(%rsp)
jmp 0x1808d
movb $0x0, 0x13e(%rsp)
movl $0x0, 0x11c(%rsp)
cmpl $0x2, 0x11c(%rsp)
jge 0x185de
movq 0x25c8(%rsp), %rax
movq 0x58(%rax), %rdi
cmpl $0x0, 0x11c(%rsp)
setne %al
movzbl %al, %esi
andl $0x1, %esi
callq 0x131f0
movq %rax, 0x110(%rsp)
movq 0x110(%rsp), %rax
testb $0x1, 0x18(%rax)
je 0x1823b
jmp 0x185c8
movq 0x110(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x19d80
movq %rax, 0x108(%rsp)
movq 0x110(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x19dd0
movq %rax, 0x100(%rsp)
leaq 0x108(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x19db0
testb $0x1, %al
jne 0x1828b
jmp 0x185c6
leaq 0x108(%rsp), %rdi
callq 0x19e00
movq (%rax), %rax
movq 0x28(%rax), %rdi
callq 0x19f10
movq %rax, 0xf8(%rsp)
leaq 0x108(%rsp), %rdi
callq 0x19e00
movq (%rax), %rax
movq 0x28(%rax), %rdi
callq 0x19f60
movq %rax, 0xf0(%rsp)
leaq 0xf8(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x19f40
testb $0x1, %al
jne 0x182eb
jmp 0x185a8
leaq 0xf8(%rsp), %rdi
callq 0x19f90
movq (%rax), %rax
testb $0x1, 0x8(%rax)
jne 0x1833e
leaq 0xf8(%rsp), %rdi
callq 0x19f90
movq (%rax), %rdi
xorl %esi, %esi
callq 0x136e0
testb $0x1, 0x8(%rax)
jne 0x1833e
leaq 0xf8(%rsp), %rdi
callq 0x19f90
movq (%rax), %rdi
movl $0x1, %esi
callq 0x136e0
testb $0x1, 0x8(%rax)
je 0x18355
leaq 0x21ae0(%rip), %rdi     # 0x39e25
movb $0x0, %al
callq 0xb840
xorl %esi, %esi
movl %esi, %edi
callq 0xbe90
movl $0x0, 0xec(%rsp)
cmpl $0x2, 0xec(%rsp)
jge 0x1858a
leaq 0xf8(%rsp), %rdi
callq 0x19f90
movq (%rax), %rax
movq 0x30(%rax), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x48(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x19f90
movsd 0x48(%rsp), %xmm0
movq (%rax), %rax
movb 0x3c(%rax), %al
andb $0x1, %al
movzbl %al, %edx
cmpl $0x0, 0xec(%rsp)
setne %al
andb $0x1, %al
movzbl %al, %esi
movl $0x1, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl %esi, %edx
cmovnel %ecx, %eax
cvtsi2sd %eax, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0xd0(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x19f90
movq (%rax), %rax
movq 0x30(%rax), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x50(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x19f90
movsd 0x50(%rsp), %xmm0
movq (%rax), %rax
movb 0x3c(%rax), %al
andb $0x1, %al
movzbl %al, %edx
cmpl $0x0, 0xec(%rsp)
setne %al
andb $0x1, %al
movzbl %al, %esi
movl $0x1, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl %esi, %edx
cmovnel %ecx, %eax
cvtsi2sd %eax, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0xd8(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x19f90
movq (%rax), %rax
movq 0x30(%rax), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x19f90
movsd 0x58(%rsp), %xmm0
movq (%rax), %rax
movb 0x3c(%rax), %al
andb $0x1, %al
movzbl %al, %edx
cmpl $0x0, 0xec(%rsp)
setne %al
andb $0x1, %al
movzbl %al, %esi
movl $0x1, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl %esi, %edx
cmovnel %ecx, %eax
cvtsi2sd %eax, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0xe0(%rsp)
movsd 0xd0(%rsp), %xmm1
movsd 0x140(%rsp), %xmm2
movsd 0xd8(%rsp), %xmm0
mulsd 0x148(%rsp), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0xe0(%rsp), %xmm0
movsd 0x150(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x2112e(%rip), %xmm1    # 0x39630
ucomisd %xmm1, %xmm0
jbe 0x18572
leaq 0xf8(%rsp), %rdi
callq 0x19f90
movq (%rax), %rdi
cmpl $0x0, 0xec(%rsp)
setne %al
movzbl %al, %esi
andl $0x1, %esi
callq 0x136e0
movq 0x10(%rax), %rax
cmpl $-0x2, 0x20(%rax)
jne 0x18572
leaq 0xf8(%rsp), %rdi
callq 0x19f90
movq (%rax), %rdi
cmpl $0x0, 0xec(%rsp)
setne %al
xorb $-0x1, %al
movzbl %al, %esi
andl $0x1, %esi
callq 0x136e0
movq 0x10(%rax), %rax
cmpl $-0x2, 0x20(%rax)
je 0x18572
movb $0x1, 0x13e(%rsp)
jmp 0x18574
movl 0xec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xec(%rsp)
jmp 0x18360
jmp 0x1858c
leaq 0xf8(%rsp), %rdi
xorl %esi, %esi
callq 0x1a020
movq %rax, 0xc8(%rsp)
jmp 0x182ac
jmp 0x185aa
leaq 0x108(%rsp), %rdi
xorl %esi, %esi
callq 0x19e90
movq %rax, 0xc0(%rsp)
jmp 0x18254
jmp 0x185c8
movl 0x11c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x11c(%rsp)
jmp 0x181f0
movl $0x0, 0x25d4(%rsp)
cmpl $0x2, 0x25d4(%rsp)
jge 0x18ba7
movslq 0x25d4(%rsp), %rax
movq 0x170(%rsp,%rax,8), %rax
movq %rax, 0xb8(%rsp)
cmpl $0x0, 0x25d4(%rsp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
testb $0x1, 0x16e(%rsp,%rax)
je 0x1865e
leaq 0x190(%rsp), %rax
addq $0xc38, %rax            # imm = 0xC38
cmpl $0x0, 0x25d4(%rsp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
imulq $0xc00, %rcx, %rcx      # imm = 0xC00
addq %rcx, %rax
movq %rax, 0x40(%rsp)
jmp 0x18683
leaq 0x190(%rsp), %rax
addq $0xc38, %rax            # imm = 0xC38
movslq 0x25d4(%rsp), %rcx
imulq $0xc00, %rcx, %rcx      # imm = 0xC00
addq %rcx, %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0xb0(%rsp)
cmpl $0x0, 0x25d4(%rsp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
testb $0x1, 0x16e(%rsp,%rax)
je 0x186bf
movq 0xb0(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, 0x38(%rsp)
jmp 0x186d0
movq 0xb0(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0xa8(%rsp)
cmpl $0x0, 0x25d4(%rsp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
testb $0x1, 0x16e(%rsp,%rax)
je 0x1870c
movq 0xa8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x30(%rsp)
jmp 0x1871d
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0xb8(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq 0xa0(%rsp), %rax
movsd 0x10(%rax), %xmm2
movq 0xb8(%rsp), %rax
movsd 0x10(%rax), %xmm1
movq 0xa0(%rsp), %rax
mulsd 0x8(%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x80(%rsp)
movq 0xb8(%rsp), %rax
movsd 0x10(%rax), %xmm0
movq 0xa0(%rsp), %rax
movsd (%rax), %xmm2
movq 0xb8(%rsp), %rax
movsd (%rax), %xmm1
movq 0xa0(%rsp), %rax
mulsd 0x10(%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x88(%rsp)
movq 0xb8(%rsp), %rax
movsd (%rax), %xmm0
movq 0xa0(%rsp), %rax
movsd 0x8(%rax), %xmm2
movq 0xb8(%rsp), %rax
movsd 0x8(%rax), %xmm1
movq 0xa0(%rsp), %rax
mulsd (%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x90(%rsp)
movsd 0x80(%rsp), %xmm1
movsd 0x190(%rsp), %xmm2
movsd 0x88(%rsp), %xmm0
mulsd 0x198(%rsp), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x90(%rsp), %xmm0
movsd 0x1a0(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x78(%rsp)
cmpl $0x0, 0x25d4(%rsp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
testb $0x1, 0x16e(%rsp,%rax)
je 0x188b4
movsd 0x20d7e(%rip), %xmm0    # 0x39628
ucomisd 0x78(%rsp), %xmm0
ja 0x188c8
jmp 0x188cd
movsd 0x78(%rsp), %xmm0
movsd 0x20d5e(%rip), %xmm1    # 0x39620
ucomisd %xmm1, %xmm0
jbe 0x188cd
jmp 0x18b8f
movq 0xa8(%rsp), %rax
cmpl $-0x2, (%rax)
je 0x188df
jmp 0x18b8f
movq 0xa0(%rsp), %rax
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x25d4(%rsp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
testb $0x1, 0x16e(%rsp,%rax)
je 0x1892f
leaq 0x190(%rsp), %rax
addq $0xc38, %rax            # imm = 0xC38
movslq 0x25d4(%rsp), %rcx
imulq $0xc00, %rcx, %rcx      # imm = 0xC00
addq %rcx, %rax
movq %rax, 0x20(%rsp)
jmp 0x18960
leaq 0x190(%rsp), %rax
addq $0xc38, %rax            # imm = 0xC38
cmpl $0x0, 0x25d4(%rsp)
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
imulq $0xc00, %rcx, %rcx      # imm = 0xC00
addq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rax
movq 0x20(%rsp), %rcx
cmpq %rcx, %rax
jne 0x18987
movl $0x1, %edi
leaq 0x214f5(%rip), %rsi     # 0x39e70
movb $0x0, %al
callq 0xbb80
jmp 0x18b8f
movb $0x1, 0x15f(%rsp)
movq 0xb8(%rsp), %rax
movsd (%rax), %xmm1
movq 0xb0(%rsp), %rax
movsd (%rax), %xmm2
movq 0xb8(%rsp), %rax
movsd 0x8(%rax), %xmm0
movq 0xb0(%rsp), %rax
mulsd 0x8(%rax), %xmm0
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movq 0xb8(%rsp), %rax
movsd 0x10(%rax), %xmm0
movq 0xb0(%rsp), %rax
movsd 0x10(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x20c35(%rip), %xmm1    # 0x39628
ucomisd %xmm1, %xmm0
jbe 0x18a03
movb $0x0, 0x13d(%rsp)
jmp 0x18a0b
movb $0x1, 0x13d(%rsp)
movq 0x25c8(%rsp), %rax
movq 0x50(%rax), %rdi
movq 0xa8(%rsp), %rax
movslq 0x4(%rax), %rsi
callq 0x19c00
movq 0x20(%rax), %rax
movq %rax, 0x70(%rsp)
movq 0x25c8(%rsp), %rax
movq 0x50(%rax), %rdi
movq 0xb8(%rsp), %rax
movslq 0x18(%rax), %rsi
callq 0x19c00
movl 0x4(%rax), %eax
movl %eax, 0x6c(%rsp)
cmpl $0x0, 0x25d4(%rsp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
testb $0x1, 0x16e(%rsp,%rax)
je 0x18a82
movq 0xb8(%rsp), %rax
movb 0x1c(%rax), %al
movb %al, 0x1f(%rsp)
jmp 0x18a93
movq 0xb8(%rsp), %rax
movb 0x1c(%rax), %al
xorb $-0x1, %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
andb $0x1, %al
movb %al, 0x6b(%rsp)
testb $0x1, 0x13f(%rsp)
je 0x18ac4
movb 0x13d(%rsp), %dl
movl $0x2, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, 0x18(%rsp)
jmp 0x18afe
testb $0x1, 0x13e(%rsp)
je 0x18aeb
movb 0x13d(%rsp), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, 0x14(%rsp)
jmp 0x18af6
movl $0x5, %eax
movl %eax, 0x14(%rsp)
jmp 0x18af6
movl 0x14(%rsp), %eax
movl %eax, 0x18(%rsp)
movl 0x18(%rsp), %eax
movl %eax, 0x64(%rsp)
movq 0x70(%rsp), %rdi
movl 0x6c(%rsp), %esi
movb 0x6b(%rsp), %al
movl 0x64(%rsp), %r8d
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
andb $0x1, %al
movzbl %al, %edx
callq 0x17920
testb $0x1, %al
jne 0x18b33
movb $0x1, 0x15e(%rsp)
jmp 0x18b35
cmpl $0x0, 0x25d4(%rsp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
testb $0x1, 0x16e(%rsp,%rax)
je 0x18b68
movq 0xb0(%rsp), %rax
movq 0x28(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, 0x8(%rsp)
jmp 0x18b7d
movq 0xb0(%rsp), %rax
movq 0x20(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0xb0(%rsp)
jmp 0x18690
jmp 0x18b91
movl 0x25d4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x25d4(%rsp)
jmp 0x185e9
testb $0x1, 0x15e(%rsp)
je 0x18bf0
leaq 0x20c4858(%rip), %rax   # 0x20dd410
cmpl $0x4, (%rax)
jl 0x18bdd
movl $0x4, %edi
leaq 0x212c6(%rip), %rsi     # 0x39e8f
movb $0x0, %al
callq 0xbb80
movq 0x25c8(%rsp), %rdi
callq 0x12200
movl 0x25e8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x25e8(%rsp)
jmp 0x18c20
testb $0x1, 0x15f(%rsp)
jne 0x18c0d
movl 0x25ec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x25ec(%rsp)
jmp 0x18c1e
movl 0x25e0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x25e0(%rsp)
jmp 0x18c20
jmp 0x18c22
movl 0x25dc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x25dc(%rsp)
jmp 0x17c56
movl 0x25ec(%rsp), %edx
movl 0x25e4(%rsp), %ecx
movl 0x25e0(%rsp), %r8d
movl 0x25e8(%rsp), %r9d
movl $0x3, %edi
leaq 0x2124d(%rip), %rsi     # 0x39eaf
movb $0x0, %al
callq 0xbb80
addq $0x25f8, %rsp           # imm = 0x25F8
retq
nopw %cs:(%rax,%rax)