// File: FreeSlave[P]vhlt/hlcsg/brush.cpp
// Function: ExpandBrush(brush_s*, int)
void ExpandBrush(brush_t* brush, const int hullnum)
{
#ifdef HLCSG_HULLBRUSH
	const hullshape_t *hs = &g_defaulthulls[hullnum];
	{ // look up the name of its hull shape in g_hullshapes[]
		const char *name = brush->hullshapes[hullnum];
		if (name && *name)
		{
			bool found = false;
			for (int i = 0; i < g_numhullshapes; i++)
			{
				const hullshape_t *s = &g_hullshapes[i];
				if (!strcmp (name, s->id))
				{
					if (found)
					{
						Warning ("Entity %i, Brush %i: Found several info_hullshape entities with the same name '%s'.",
#ifdef HLCSG_COUNT_NEW
							brush->originalentitynum, brush->originalbrushnum,
#else
							brush->entitynum, brush->brushnum,
#endif
							name);
					}
					hs = s;
					found = true;
				}
			}
			if (!found)
			{
				Error ("Entity %i, Brush %i: Couldn't find info_hullshape entity '%s'.",
#ifdef HLCSG_COUNT_NEW
					brush->originalentitynum, brush->originalbrushnum,
#else
					brush->entitynum, brush->brushnum,
#endif
					name);
			}
		}
	}

	if (!hs->disabled)
	{
		if (hs->numbrushes == 0)
		{
			return; // leave this hull of this brush empty (noclip)
		}
		ExpandBrushWithHullBrush (brush, &brush->hulls[0], hs->brushes[0], &brush->hulls[hullnum]);

		return;
	}
#endif
	//for looping through the faces and constructing the hull
	bface_t* current_face;
	plane_t* current_plane;
	brushhull_t* hull;
	vec3_t	origin, normal;

	//for non-axial bevel testing
	Winding* winding;
	bface_t* other_face;
	plane_t* other_plane;
	Winding* other_winding;
	vec3_t  edge_start, edge_end, edge, bevel_edge;
	unsigned int counter, counter2, dir;
	bool start_found,end_found;
	bool axialbevel[last_axial+1][2] = { {false,false}, {false,false}, {false,false} };

	bool warned = false;

	hull = &brush->hulls[hullnum];

	// step 1: for collision between player vertex and brush face. --vluzacn
	for(current_face = brush->hulls[0].faces; current_face; current_face = current_face->next)
	{
		current_plane = current_face->plane;

		//don't bother adding axial planes,
		//they're defined by adding the bounding box anyway
		if(current_plane->type <= last_axial)
		{
			//flag case where bounding box shouldn't expand
#ifdef HLCSG_CUSTOMHULL
			if (current_face->bevel)
#else
			if((g_texinfo[current_face->texinfo].flags & TEX_BEVEL))
#endif
			{
				switch(current_plane->type)
				{
				case plane_x:
					axialbevel[plane_x][(current_plane->normal[0] > 0 ? 1 : 0)] = true;
					break;
				case plane_y:
					axialbevel[plane_y][(current_plane->normal[1] > 0 ? 1 : 0)] = true;
					break;
				case plane_z:
					axialbevel[plane_z][(current_plane->normal[2] > 0 ? 1 : 0)] = true;
					break;
				}
			}
			continue;
		}

		//add the offset non-axial plane to the expanded hull
        VectorCopy(current_plane->origin, origin);
        VectorCopy(current_plane->normal, normal);

		//old code multiplied offset by normal -- this led to post-csg "sticky" walls where a
		//slope met an axial plane from the next brush since the offset from the slope would be less
		//than the full offset for the axial plane -- the discontinuity also contributes to increased
		//clipnodes.  If the normal is zero along an axis, shifting the origin in that direction won't
		//change the plane number, so I don't explicitly test that case.  The old method is still used if
		//preciseclip is turned off to allow backward compatability -- some of the improperly beveled edges
		//grow using the new origins, and might cause additional problems.

#ifdef HLCSG_CUSTOMHULL
		if (current_face->bevel)
#else
		if((g_texinfo[current_face->texinfo].flags & TEX_BEVEL))
#endif
		{
			//don't adjust origin - we'll correct g_texinfo's flags in a later step
		}
#ifdef HLCSG_CLIPTYPEPRECISE_EPSILON_FIX
		// The old offset will generate an extremely small gap when the normal is close to axis, causing epsilon errors (ambiguous leafnode content, player falling into ground, etc.).
		// For example: with the old shifting method, slopes with angle arctan(1/8) and arctan(1/64) will result in gaps of 0.0299 unit and 0.000488 unit respectively, which are smaller than ON_EPSILON, while in both 'simple' cliptype and the new method, the gaps are 2.0 units and 0.25 unit, which are good.
		// This also reduce the number of clipnodes used for cliptype precise.
		// The maximum difference in height between the old offset and the new offset is 0.86 unit for standing player and 6.9 units for ducking player. (when FLOOR_Z = 0.7)
		// And another reason not to use the old offset is that the old offset is quite wierd. It might appears at first glance that it regards the player as an ellipse, but in fact it isn't, and the player's feet may even sink slightly into the ground theoretically for slopes of certain angles.
		else if (g_cliptype == clip_precise && normal[2] > FLOOR_Z)
		{
			origin[0] += 0;
			origin[1] += 0;
			origin[2] += g_hull_size[hullnum][1][2];
		}
		else if (g_cliptype == clip_legacy || g_cliptype == clip_normalized)
#else
		else if(g_cliptype == clip_legacy || (g_cliptype == clip_precise && (normal[2] > FLOOR_Z)) || g_cliptype == clip_normalized)
#endif
		{
			if(normal[0])
			{ origin[0] += normal[0] * (normal[0] > 0 ? g_hull_size[hullnum][1][0] : -g_hull_size[hullnum][0][0]); }
			if(normal[1])
			{ origin[1] += normal[1] * (normal[1] > 0 ? g_hull_size[hullnum][1][1] : -g_hull_size[hullnum][0][1]); }
			if(normal[2])
			{ origin[2] += normal[2] * (normal[2] > 0 ? g_hull_size[hullnum][1][2] : -g_hull_size[hullnum][0][2]); }
		}
		else
		{
			origin[0] += g_hull_size[hullnum][(normal[0] > 0 ? 1 : 0)][0];
			origin[1] += g_hull_size[hullnum][(normal[1] > 0 ? 1 : 0)][1];
			origin[2] += g_hull_size[hullnum][(normal[2] > 0 ? 1 : 0)][2];
		}

		AddHullPlane(hull,normal,origin,false);
	}

// Assembly:
subq $0x258, %rsp            # imm = 0x258
movq %rdi, 0x250(%rsp)
movl %esi, 0x24c(%rsp)
movslq 0x24c(%rsp), %rcx
leaq 0x30c685b(%rip), %rax   # 0x30da9b0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x240(%rsp)
movq 0x250(%rsp), %rax
movslq 0x24c(%rsp), %rcx
movq 0x38(%rax,%rcx,8), %rax
movq %rax, 0x238(%rsp)
cmpq $0x0, 0x238(%rsp)
je 0x1429e
movq 0x238(%rsp), %rax
cmpb $0x0, (%rax)
je 0x1429e
movb $0x0, 0x237(%rsp)
movl $0x0, 0x230(%rsp)
movl 0x230(%rsp), %eax
cmpl 0x30c684f(%rip), %eax   # 0x30daa10
jge 0x14267
movslq 0x230(%rsp), %rcx
leaq 0x30c684a(%rip), %rax   # 0x30daa20
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x228(%rsp)
movq 0x238(%rsp), %rdi
movq 0x228(%rsp), %rax
movq (%rax), %rsi
callq 0x4530
cmpl $0x0, %eax
jne 0x1424f
testb $0x1, 0x237(%rsp)
je 0x14237
movq 0x250(%rsp), %rax
movl (%rax), %esi
movq 0x250(%rsp), %rax
movl 0x4(%rax), %edx
movq 0x238(%rsp), %rcx
leaq 0x19578(%rip), %rdi     # 0x2d7a8
movb $0x0, %al
callq 0xbef0
movq 0x228(%rsp), %rax
movq %rax, 0x240(%rsp)
movb $0x1, 0x237(%rsp)
jmp 0x14251
movl 0x230(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x230(%rsp)
jmp 0x141b4
testb $0x1, 0x237(%rsp)
jne 0x1429c
movq 0x250(%rsp), %rax
movl (%rax), %esi
movq 0x250(%rsp), %rax
movl 0x4(%rax), %edx
movq 0x238(%rsp), %rcx
leaq 0x19567(%rip), %rdi     # 0x2d7fc
movb $0x0, %al
callq 0xba80
jmp 0x1429e
movq 0x240(%rsp), %rax
testb $0x1, 0x8(%rax)
jne 0x14307
movq 0x240(%rsp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x142bf
jmp 0x157e9
movq 0x250(%rsp), %rdi
movq 0x250(%rsp), %rsi
addq $0x60, %rsi
movq 0x240(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rdx
movq 0x250(%rsp), %rcx
addq $0x60, %rcx
movslq 0x24c(%rsp), %rax
imulq $0x38, %rax, %rax
addq %rax, %rcx
callq 0x12ce0
jmp 0x157e9
leaq 0x11c(%rsp), %rdi
xorl %esi, %esi
movl $0x6, %edx
callq 0x4210
movb $0x0, 0x11b(%rsp)
movq 0x250(%rsp), %rax
addq $0x60, %rax
movslq 0x24c(%rsp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x210(%rsp)
movq 0x250(%rsp), %rax
movq 0x90(%rax), %rax
movq %rax, 0x220(%rsp)
cmpq $0x0, 0x220(%rsp)
je 0x1491a
movq 0x220(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x218(%rsp)
movq 0x218(%rsp), %rax
cmpl $0x2, 0x38(%rax)
jg 0x1445a
movq 0x220(%rsp), %rax
testb $0x1, 0x30(%rax)
je 0x14455
movq 0x218(%rsp), %rax
movl 0x38(%rax), %eax
movl %eax, 0x114(%rsp)
testl %eax, %eax
je 0x143d8
jmp 0x143bc
movl 0x114(%rsp), %eax
subl $0x1, %eax
je 0x14401
jmp 0x143ca
movl 0x114(%rsp), %eax
subl $0x2, %eax
je 0x1442b
jmp 0x14453
movq 0x218(%rsp), %rax
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
xorl %eax, %eax
movl $0x1, %ecx
ucomisd %xmm1, %xmm0
cmoval %ecx, %eax
cltq
movb $0x1, 0x11c(%rsp,%rax)
jmp 0x14453
movq 0x218(%rsp), %rax
movsd 0x8(%rax), %xmm0
xorps %xmm1, %xmm1
xorl %eax, %eax
movl $0x1, %ecx
ucomisd %xmm1, %xmm0
cmoval %ecx, %eax
cltq
movb $0x1, 0x11e(%rsp,%rax)
jmp 0x14453
movq 0x218(%rsp), %rax
movsd 0x10(%rax), %xmm0
xorps %xmm1, %xmm1
xorl %eax, %eax
movl $0x1, %ecx
ucomisd %xmm1, %xmm0
cmoval %ecx, %eax
cltq
movb $0x1, 0x120(%rsp,%rax)
jmp 0x14455
jmp 0x14902
movq 0x218(%rsp), %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, 0x1f0(%rsp)
movq 0x218(%rsp), %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, 0x1f8(%rsp)
movq 0x218(%rsp), %rax
movsd 0x28(%rax), %xmm0
movsd %xmm0, 0x200(%rsp)
movq 0x218(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x1d0(%rsp)
movq 0x218(%rsp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x1d8(%rsp)
movq 0x218(%rsp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0x1e0(%rsp)
movq 0x220(%rsp), %rax
testb $0x1, 0x30(%rax)
je 0x144f0
jmp 0x148e3
leaq 0x22fc1(%rip), %rax     # 0x374b8
cmpl $0x3, (%rax)
jne 0x1456f
movsd 0x1e0(%rsp), %xmm0
movsd 0x19183(%rip), %xmm1    # 0x2d690
ucomisd %xmm1, %xmm0
jbe 0x1456f
xorps %xmm0, %xmm0
addsd 0x1f0(%rsp), %xmm0
movsd %xmm0, 0x1f0(%rsp)
xorps %xmm0, %xmm0
addsd 0x1f8(%rsp), %xmm0
movsd %xmm0, 0x1f8(%rsp)
movslq 0x24c(%rsp), %rcx
leaq 0x22ea4(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x28(%rax), %xmm0
addsd 0x200(%rsp), %xmm0
movsd %xmm0, 0x200(%rsp)
jmp 0x148e1
leaq 0x22f42(%rip), %rax     # 0x374b8
cmpl $0x4, (%rax)
je 0x1458b
leaq 0x22f36(%rip), %rax     # 0x374b8
cmpl $0x1, (%rax)
jne 0x147ed
movsd 0x1d0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x145a4
jp 0x145a4
jmp 0x14654
movsd 0x1d0(%rsp), %xmm0
movsd %xmm0, 0x108(%rsp)
movsd 0x1d0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x145ee
movslq 0x24c(%rsp), %rcx
leaq 0x22e19(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, 0x100(%rsp)
jmp 0x14628
movslq 0x24c(%rsp), %rcx
leaq 0x22df3(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, 0x100(%rsp)
movsd 0x108(%rsp), %xmm0
movsd 0x100(%rsp), %xmm2
movsd 0x1f0(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1f0(%rsp)
movsd 0x1d8(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1466d
jp 0x1466d
jmp 0x1471e
movsd 0x1d8(%rsp), %xmm0
movsd %xmm0, 0xf8(%rsp)
movsd 0x1d8(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x146b7
movslq 0x24c(%rsp), %rcx
leaq 0x22d50(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, 0xf0(%rsp)
jmp 0x146f2
movslq 0x24c(%rsp), %rcx
leaq 0x22d2a(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, 0xf0(%rsp)
movsd 0xf8(%rsp), %xmm0
movsd 0xf0(%rsp), %xmm2
movsd 0x1f8(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1f8(%rsp)
movsd 0x1e0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x14737
jp 0x14737
jmp 0x147e8
movsd 0x1e0(%rsp), %xmm0
movsd %xmm0, 0xe8(%rsp)
movsd 0x1e0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x14781
movslq 0x24c(%rsp), %rcx
leaq 0x22c86(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x28(%rax), %xmm0
movsd %xmm0, 0xe0(%rsp)
jmp 0x147bc
movslq 0x24c(%rsp), %rcx
leaq 0x22c60(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, 0xe0(%rsp)
movsd 0xe8(%rsp), %xmm0
movsd 0xe0(%rsp), %xmm2
movsd 0x200(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x200(%rsp)
jmp 0x148df
movslq 0x24c(%rsp), %rcx
leaq 0x22bf4(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x1d0(%rsp), %xmm0
xorps %xmm1, %xmm1
xorl %ecx, %ecx
movl $0x1, %edx
ucomisd %xmm1, %xmm0
cmoval %edx, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
addsd 0x1f0(%rsp), %xmm0
movsd %xmm0, 0x1f0(%rsp)
movslq 0x24c(%rsp), %rcx
leaq 0x22ba4(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x1d8(%rsp), %xmm0
xorps %xmm1, %xmm1
xorl %ecx, %ecx
movl $0x1, %edx
ucomisd %xmm1, %xmm0
cmoval %edx, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
addsd 0x1f8(%rsp), %xmm0
movsd %xmm0, 0x1f8(%rsp)
movslq 0x24c(%rsp), %rcx
leaq 0x22b53(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x1e0(%rsp), %xmm0
xorps %xmm1, %xmm1
xorl %ecx, %ecx
movl $0x1, %edx
ucomisd %xmm1, %xmm0
cmoval %edx, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
addsd 0x200(%rsp), %xmm0
movsd %xmm0, 0x200(%rsp)
jmp 0x148e1
jmp 0x148e3
movq 0x210(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
leaq 0x1f0(%rsp), %rdx
xorl %ecx, %ecx
callq 0x12bf0
movq 0x220(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x220(%rsp)
jmp 0x1435d
leaq 0x22b97(%rip), %rax     # 0x374b8
cmpl $0x2, (%rax)
je 0x14942
leaq 0x22b8b(%rip), %rax     # 0x374b8
cmpl $0x3, (%rax)
je 0x14942
leaq 0x22b7f(%rip), %rax     # 0x374b8
cmpl $0x1, (%rax)
jne 0x153bb
movq 0x250(%rsp), %rax
movq 0x90(%rax), %rax
movq %rax, 0x220(%rsp)
cmpq $0x0, 0x220(%rsp)
je 0x153b9
movq 0x220(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x218(%rsp)
movq 0x220(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x1c8(%rsp)
movl $0x0, 0x12c(%rsp)
movl 0x12c(%rsp), %eax
movq 0x1c8(%rsp), %rcx
cmpl 0x8(%rcx), %eax
jae 0x1539f
movq 0x1c8(%rsp), %rax
movq 0x10(%rax), %rax
movl 0x12c(%rsp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x190(%rsp)
movq 0x1c8(%rsp), %rax
movq 0x10(%rax), %rax
movl 0x12c(%rsp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x198(%rsp)
movq 0x1c8(%rsp), %rax
movq 0x10(%rax), %rax
movl 0x12c(%rsp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0x1a0(%rsp)
movq 0x1c8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0xc8(%rsp)
movl 0x12c(%rsp), %eax
addl $0x1, %eax
movq 0x1c8(%rsp), %rcx
xorl %edx, %edx
divl 0x8(%rcx)
movq 0xc8(%rsp), %rax
movl %edx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x170(%rsp)
movq 0x1c8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0xd0(%rsp)
movl 0x12c(%rsp), %eax
addl $0x1, %eax
movq 0x1c8(%rsp), %rcx
xorl %edx, %edx
divl 0x8(%rcx)
movq 0xd0(%rsp), %rax
movl %edx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x178(%rsp)
movq 0x1c8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0xd8(%rsp)
movl 0x12c(%rsp), %eax
addl $0x1, %eax
movq 0x1c8(%rsp), %rcx
xorl %edx, %edx
divl 0x8(%rcx)
movq 0xd8(%rsp), %rax
movl %edx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, 0x180(%rsp)
movsd 0x170(%rsp), %xmm0
subsd 0x190(%rsp), %xmm0
movsd %xmm0, 0x150(%rsp)
movsd 0x178(%rsp), %xmm0
subsd 0x198(%rsp), %xmm0
movsd %xmm0, 0x158(%rsp)
movsd 0x180(%rsp), %xmm0
subsd 0x1a0(%rsp), %xmm0
movsd %xmm0, 0x160(%rsp)
movq 0x250(%rsp), %rax
movq 0x90(%rax), %rax
movq %rax, 0x1c0(%rsp)
cmpq $0x0, 0x1c0(%rsp)
je 0x14cb8
movq 0x1c0(%rsp), %rax
cmpq 0x220(%rsp), %rax
jne 0x14b95
jmp 0x14ca0
movb $0x0, 0x123(%rsp)
movb $0x0, 0x122(%rsp)
movq 0x1c0(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x1b0(%rsp)
movl $0x0, 0x128(%rsp)
movl 0x128(%rsp), %eax
movq 0x1b0(%rsp), %rcx
cmpl 0x8(%rcx), %eax
jae 0x14c88
testb $0x1, 0x123(%rsp)
jne 0x14c1b
movq 0x1b0(%rsp), %rax
movq 0x10(%rax), %rdi
movl 0x128(%rsp), %eax
imulq $0x18, %rax, %rax
addq %rax, %rdi
leaq 0x190(%rsp), %rsi
callq 0x18f00
testb $0x1, %al
jne 0x14c13
jmp 0x14c1b
movb $0x1, 0x123(%rsp)
testb $0x1, 0x122(%rsp)
jne 0x14c5a
movq 0x1b0(%rsp), %rax
movq 0x10(%rax), %rdi
movl 0x128(%rsp), %eax
imulq $0x18, %rax, %rax
addq %rax, %rdi
leaq 0x170(%rsp), %rsi
callq 0x18f00
testb $0x1, %al
jne 0x14c52
jmp 0x14c5a
movb $0x1, 0x122(%rsp)
testb $0x1, 0x123(%rsp)
je 0x14c70
testb $0x1, 0x122(%rsp)
je 0x14c70
jmp 0x14c88
jmp 0x14c72
movl 0x128(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x128(%rsp)
jmp 0x14bc4
testb $0x1, 0x123(%rsp)
je 0x14c9e
testb $0x1, 0x122(%rsp)
je 0x14c9e
jmp 0x14cb8
jmp 0x14ca0
movq 0x1c0(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1c0(%rsp)
jmp 0x14b6f
cmpq $0x0, 0x1c0(%rsp)
jne 0x14d07
cmpl $0x1, 0x24c(%rsp)
jne 0x14d02
testb $0x1, 0x11b(%rsp)
jne 0x14d02
movq 0x250(%rsp), %rax
movl (%rax), %esi
movq 0x250(%rsp), %rax
movl 0x4(%rax), %edx
leaq 0x18a74(%rip), %rdi     # 0x2d767
movb $0x0, %al
callq 0xbef0
movb $0x1, 0x11b(%rsp)
jmp 0x15389
movq 0x1c0(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x1b8(%rsp)
movl $0x0, 0x124(%rsp)
cmpl $0x3, 0x124(%rsp)
jae 0x15387
movq 0x218(%rsp), %rax
movl 0x124(%rsp), %ecx
movsd (%rax,%rcx,8), %xmm1
movq 0x1b8(%rsp), %rax
movl 0x124(%rsp), %ecx
mulsd (%rax,%rcx,8), %xmm1
movsd 0x18924(%rip), %xmm0    # 0x2d688
ucomisd %xmm1, %xmm0
jbe 0x1536f
xorps %xmm0, %xmm0
movsd %xmm0, 0x140(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x138(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x130(%rsp)
movq 0x218(%rsp), %rax
movl 0x124(%rsp), %ecx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
movl $0x1, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
ucomisd %xmm1, %xmm0
cmoval %ecx, %eax
cvtsi2sd %eax, %xmm0
movl 0x124(%rsp), %eax
movsd %xmm0, 0x130(%rsp,%rax,8)
movsd 0x158(%rsp), %xmm0
movsd 0x140(%rsp), %xmm2
movsd 0x160(%rsp), %xmm1
mulsd 0x138(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1d0(%rsp)
movsd 0x160(%rsp), %xmm0
movsd 0x130(%rsp), %xmm2
movsd 0x150(%rsp), %xmm1
mulsd 0x140(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1d8(%rsp)
movsd 0x150(%rsp), %xmm0
movsd 0x138(%rsp), %xmm2
movsd 0x158(%rsp), %xmm1
mulsd 0x130(%rsp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1e0(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0x121b0
movl 0x124(%rsp), %eax
addl $0x1, %eax
movl $0x3, %ecx
xorl %edx, %edx
divl %ecx
movl %edx, %eax
movsd 0x1d0(%rsp,%rax,8), %xmm1
movaps 0x185cc(%rip), %xmm0    # 0x2d4b0
pand %xmm0, %xmm1
movsd 0x15178(%rip), %xmm0    # 0x2a068
ucomisd %xmm1, %xmm0
jae 0x14f2d
movl 0x124(%rsp), %eax
addl $0x2, %eax
movl $0x3, %ecx
xorl %edx, %edx
divl %ecx
movl %edx, %eax
movsd 0x1d0(%rsp,%rax,8), %xmm1
movaps 0x18595(%rip), %xmm0    # 0x2d4b0
pand %xmm0, %xmm1
movsd 0x15141(%rip), %xmm0    # 0x2a068
ucomisd %xmm1, %xmm0
jb 0x14f32
jmp 0x15371
movsd 0x190(%rsp), %xmm0
movsd %xmm0, 0x1f0(%rsp)
movsd 0x198(%rsp), %xmm0
movsd %xmm0, 0x1f8(%rsp)
movsd 0x1a0(%rsp), %xmm0
movsd %xmm0, 0x200(%rsp)
leaq 0x22549(%rip), %rax     # 0x374b8
cmpl $0x3, (%rax)
jne 0x14fe7
movsd 0x1e0(%rsp), %xmm0
movsd 0x1870b(%rip), %xmm1    # 0x2d690
ucomisd %xmm1, %xmm0
jbe 0x14fe7
xorps %xmm0, %xmm0
addsd 0x1f0(%rsp), %xmm0
movsd %xmm0, 0x1f0(%rsp)
xorps %xmm0, %xmm0
addsd 0x1f8(%rsp), %xmm0
movsd %xmm0, 0x1f8(%rsp)
movslq 0x24c(%rsp), %rcx
leaq 0x2242c(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x28(%rax), %xmm0
addsd 0x200(%rsp), %xmm0
movsd %xmm0, 0x200(%rsp)
jmp 0x1534d
leaq 0x224ca(%rip), %rax     # 0x374b8
cmpl $0x1, (%rax)
jne 0x15259
movsd 0x1d0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x15010
jp 0x15010
jmp 0x150c0
movsd 0x1d0(%rsp), %xmm0
movsd %xmm0, 0xc0(%rsp)
movsd 0x1d0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1505a
movslq 0x24c(%rsp), %rcx
leaq 0x223ad(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, 0xb8(%rsp)
jmp 0x15094
movslq 0x24c(%rsp), %rcx
leaq 0x22387(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, 0xb8(%rsp)
movsd 0xc0(%rsp), %xmm0
movsd 0xb8(%rsp), %xmm2
movsd 0x1f0(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1f0(%rsp)
movsd 0x1d8(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x150d9
jp 0x150d9
jmp 0x1518a
movsd 0x1d8(%rsp), %xmm0
movsd %xmm0, 0xb0(%rsp)
movsd 0x1d8(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x15123
movslq 0x24c(%rsp), %rcx
leaq 0x222e4(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, 0xa8(%rsp)
jmp 0x1515e
movslq 0x24c(%rsp), %rcx
leaq 0x222be(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, 0xa8(%rsp)
movsd 0xb0(%rsp), %xmm0
movsd 0xa8(%rsp), %xmm2
movsd 0x1f8(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x1f8(%rsp)
movsd 0x1e0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x151a3
jp 0x151a3
jmp 0x15254
movsd 0x1e0(%rsp), %xmm0
movsd %xmm0, 0xa0(%rsp)
movsd 0x1e0(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x151ed
movslq 0x24c(%rsp), %rcx
leaq 0x2221a(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x28(%rax), %xmm0
movsd %xmm0, 0x98(%rsp)
jmp 0x15228
movslq 0x24c(%rsp), %rcx
leaq 0x221f4(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, 0x98(%rsp)
movsd 0xa0(%rsp), %xmm0
movsd 0x98(%rsp), %xmm2
movsd 0x200(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x200(%rsp)
jmp 0x1534b
movslq 0x24c(%rsp), %rcx
leaq 0x22188(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x1d0(%rsp), %xmm0
xorps %xmm1, %xmm1
xorl %ecx, %ecx
movl $0x1, %edx
ucomisd %xmm1, %xmm0
cmoval %edx, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
addsd 0x1f0(%rsp), %xmm0
movsd %xmm0, 0x1f0(%rsp)
movslq 0x24c(%rsp), %rcx
leaq 0x22138(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x1d8(%rsp), %xmm0
xorps %xmm1, %xmm1
xorl %ecx, %ecx
movl $0x1, %edx
ucomisd %xmm1, %xmm0
cmoval %edx, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
addsd 0x1f8(%rsp), %xmm0
movsd %xmm0, 0x1f8(%rsp)
movslq 0x24c(%rsp), %rcx
leaq 0x220e7(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x1e0(%rsp), %xmm0
xorps %xmm1, %xmm1
xorl %ecx, %ecx
movl $0x1, %edx
ucomisd %xmm1, %xmm0
cmoval %edx, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
addsd 0x200(%rsp), %xmm0
movsd %xmm0, 0x200(%rsp)
jmp 0x1534d
movq 0x210(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
leaq 0x1f0(%rsp), %rdx
movl $0x1, %ecx
callq 0x12bf0
jmp 0x15371
movl 0x124(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x124(%rsp)
jmp 0x14d26
jmp 0x15389
movl 0x12c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x12c(%rsp)
jmp 0x1499b
jmp 0x153a1
movq 0x220(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x220(%rsp)
jmp 0x14959
jmp 0x153bb
movq 0x250(%rsp), %rax
movsd 0x60(%rax), %xmm0
movslq 0x24c(%rsp), %rcx
leaq 0x22019(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd (%rax), %xmm0
movsd %xmm0, 0x1f0(%rsp)
movq 0x250(%rsp), %rax
movsd 0x68(%rax), %xmm0
movslq 0x24c(%rsp), %rcx
leaq 0x21fe9(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x8(%rax), %xmm0
movsd %xmm0, 0x1f8(%rsp)
movq 0x250(%rsp), %rax
movsd 0x70(%rax), %xmm0
movslq 0x24c(%rsp), %rcx
leaq 0x21fb8(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x10(%rax), %xmm0
movsd %xmm0, 0x200(%rsp)
movsd 0x18053(%rip), %xmm0    # 0x2d4a8
movsd %xmm0, 0x1d0(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1d8(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1e0(%rsp)
movq 0x210(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x1d0(%rsp), %rax
movq %rax, 0x90(%rsp)
testb $0x1, 0x11c(%rsp)
je 0x154b6
movq 0x250(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x80(%rsp)
jmp 0x154c8
leaq 0x1f0(%rsp), %rax
movq %rax, 0x80(%rsp)
jmp 0x154c8
movq 0x90(%rsp), %rsi
movq 0x88(%rsp), %rdi
movq 0x80(%rsp), %rdx
xorl %ecx, %ecx
callq 0x12bf0
xorps %xmm0, %xmm0
movsd %xmm0, 0x1d0(%rsp)
movsd 0x17fad(%rip), %xmm0    # 0x2d4a8
movsd %xmm0, 0x1d8(%rsp)
movq 0x210(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x1d0(%rsp), %rax
movq %rax, 0x78(%rsp)
testb $0x1, 0x11e(%rsp)
je 0x1553b
movq 0x250(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x68(%rsp)
jmp 0x1554a
leaq 0x1f0(%rsp), %rax
movq %rax, 0x68(%rsp)
jmp 0x1554a
movq 0x78(%rsp), %rsi
movq 0x70(%rsp), %rdi
movq 0x68(%rsp), %rdx
xorl %ecx, %ecx
callq 0x12bf0
xorps %xmm0, %xmm0
movsd %xmm0, 0x1d8(%rsp)
movsd 0x17f34(%rip), %xmm0    # 0x2d4a8
movsd %xmm0, 0x1e0(%rsp)
movq 0x210(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0x1d0(%rsp), %rax
movq %rax, 0x60(%rsp)
testb $0x1, 0x120(%rsp)
je 0x155b4
movq 0x250(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x50(%rsp)
jmp 0x155c3
leaq 0x1f0(%rsp), %rax
movq %rax, 0x50(%rsp)
jmp 0x155c3
movq 0x60(%rsp), %rsi
movq 0x58(%rsp), %rdi
movq 0x50(%rsp), %rdx
xorl %ecx, %ecx
callq 0x12bf0
xorps %xmm0, %xmm0
movsd %xmm0, 0x1e0(%rsp)
movq 0x250(%rsp), %rax
movsd 0x78(%rax), %xmm0
movslq 0x24c(%rsp), %rcx
leaq 0x21def(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x18(%rax), %xmm0
movsd %xmm0, 0x1f0(%rsp)
movq 0x250(%rsp), %rax
movsd 0x80(%rax), %xmm0
movslq 0x24c(%rsp), %rcx
leaq 0x21dbb(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x20(%rax), %xmm0
movsd %xmm0, 0x1f8(%rsp)
movq 0x250(%rsp), %rax
movsd 0x88(%rax), %xmm0
movslq 0x24c(%rsp), %rcx
leaq 0x21d87(%rip), %rax     # 0x373f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
addsd 0x28(%rax), %xmm0
movsd %xmm0, 0x200(%rsp)
movsd 0x17af2(%rip), %xmm0    # 0x2d178
movsd %xmm0, 0x1d0(%rsp)
movq 0x210(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x1d0(%rsp), %rax
movq %rax, 0x48(%rsp)
testb $0x1, 0x11d(%rsp)
je 0x156ca
movq 0x250(%rsp), %rax
addq $0x60, %rax
addq $0x18, %rax
movq %rax, 0x38(%rsp)
jmp 0x156d9
leaq 0x1f0(%rsp), %rax
movq %rax, 0x38(%rsp)
jmp 0x156d9
movq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rdx
xorl %ecx, %ecx
callq 0x12bf0
xorps %xmm0, %xmm0
movsd %xmm0, 0x1d0(%rsp)
movsd 0x17a75(%rip), %xmm0    # 0x2d178
movsd %xmm0, 0x1d8(%rsp)
movq 0x210(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x1d0(%rsp), %rax
movq %rax, 0x30(%rsp)
testb $0x1, 0x11f(%rsp)
je 0x15747
movq 0x250(%rsp), %rax
addq $0x60, %rax
addq $0x18, %rax
movq %rax, 0x20(%rsp)
jmp 0x15756
leaq 0x1f0(%rsp), %rax
movq %rax, 0x20(%rsp)
jmp 0x15756
movq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
xorl %ecx, %ecx
callq 0x12bf0
xorps %xmm0, %xmm0
movsd %xmm0, 0x1d8(%rsp)
movsd 0x179f8(%rip), %xmm0    # 0x2d178
movsd %xmm0, 0x1e0(%rsp)
movq 0x210(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x1d0(%rsp), %rax
movq %rax, 0x18(%rsp)
testb $0x1, 0x121(%rsp)
je 0x157c4
movq 0x250(%rsp), %rax
addq $0x60, %rax
addq $0x18, %rax
movq %rax, 0x8(%rsp)
jmp 0x157d3
leaq 0x1f0(%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0x157d3
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rdx
xorl %ecx, %ecx
callq 0x12bf0
addq $0x258, %rsp            # imm = 0x258
retq
nopw %cs:(%rax,%rax)