// File: /workspace/github_cpp_makefile_star2_O3/MarkCBell[P]twister/./twister/kernel/twister.cpp
// Function: manifold::canonical_peripheral_curves(tetra*)
void manifold::canonical_peripheral_curves(tetra *capoff_tetra)
{
	output_debugging("L&M", 2);
	
	if (!last_tetra)  // Empty manifold?
		return;
	
	if (capoff_tetra == NULL)  // We don't want to calculate this or there's no boundary faces.
		return;
	
	// Clear everything.
	for (tetra *current = capoff_tetra; current != NULL; current = current->get_next())
		current->set_temp(-1);
	
	// Start by assuming that we're building a bundle.
	// First we deal with the cusps coming from marked points of the surface.
	// Here the longitude is canonical (coming from the surface) and the 
	// dual 'meridian' slope is chosen to be shortest in the triangulation.
	// The longitude runs clockwise around the marked point (as seen on the surface
	// from above) while the meridian runs upwards (into your eye).
	for (tetra *basepoint = capoff_tetra; basepoint != NULL; basepoint = basepoint->get_next())
	{
		// Non-toroidal cusps have cusp number -1; avoid them.
		if ((basepoint->get_temp() != -1) || (basepoint->get_cusp_number() == -1)) continue;
		
		if (basepoint->get_layer() != num_layers) continue;
		
		// Work out the longitude.
		int bad_dir = 0;  // This will be the direction to move in to get out of this layer.
		for (bad_dir = 0; bad_dir < 3; bad_dir++)  // Work out the starting direction (actually the direction NOT to go in).
			if ((basepoint->get_gluedto(bad_dir))->get_layer() != num_layers) break;
		
		int back_dir = (bad_dir + 2) % 3;  // This will always hold the direction pointing back the way we just moved. Never go back this way.
		
		// Starting at the basepoint, install longitude until we get back to the basepoint.
		// NEVER exit the current layer.
		for (tetra *current = basepoint, *adjacent = NULL; adjacent != basepoint; current = adjacent)
		{
			current->set_temp(-2);
			for (int dir = 0; dir < 3; dir++)
			{
				if (dir == back_dir) continue;  // Don't move backwards.
				adjacent = current->get_gluedto(dir);
				if (adjacent->get_layer() != num_layers) continue;  // Don't move out of this layer.
				
				back_dir = (current->get_gluing(dir))[dir];  // Find out which way will take us backwards.
				current->set_peripheral_curves(longitude, dir, -1);  // Install the longitude in this direction.
				adjacent->set_peripheral_curves(longitude, back_dir, 1);
				break;
			}
		}
		
		// Now work out the meridian.
		// We look for a start and end on opposite sides of the longitude.
		int start_basepoint_dir = bad_dir, end_basepoint_dir = dual_direction(basepoint);
		
		tetra *start_basepoint = basepoint->get_gluedto(start_basepoint_dir);
		tetra *end_basepoint = basepoint->get_gluedto(end_basepoint_dir);
		
		// Start the meridian information.
		basepoint->set_peripheral_curves(meridian, start_basepoint_dir, -1);
		basepoint->set_peripheral_curves(meridian, end_basepoint_dir, 1);
		back_dir = (basepoint->get_gluing(end_basepoint_dir))[end_basepoint_dir];
		end_basepoint->set_peripheral_curves(meridian, back_dir, -1);
		back_dir = (basepoint->get_gluing(start_basepoint_dir))[start_basepoint_dir];
		start_basepoint->set_peripheral_curves(meridian, back_dir, 1);
		
		// Now find a path from start to end without crossing the longitude.
		// Remember, ones in the longitude have a temp of -2.
		
		// Flow distance forwards.
		int old_start_basepoint_temp = start_basepoint->get_temp();
		start_basepoint->set_temp(0);  // Seed flow at start_basepoint.
		int old_end_basepoint_temp = end_basepoint->get_temp();
		end_basepoint->set_temp(-1);  // Must allow the flow into end_basepoint.
		
		std::queue<tetra *> tetra_list;
		tetra_list.push(start_basepoint);
		while ((end_basepoint->get_temp() == -1) && !(tetra_list.empty()))
		{
			tetra *current = tetra_list.front();
			tetra_list.pop();
			for (int i = 0; i < 3; i++)
			{
				tetra *adjacent = current->get_gluedto(i);
				if (adjacent->get_temp() == -1)
				{
					adjacent->set_temp(current->get_temp() + 1);
					tetra_list.push(adjacent);
				}
			}
		}
		
		if (end_basepoint->get_temp() == -1)  // If the longitude was separating then clean up.
		{
			output_debugging("clean", 3);
			start_basepoint->set_temp(old_start_basepoint_temp);
			end_basepoint->set_temp(old_end_basepoint_temp);
			
			for (tetra *current = capoff_tetra; current != NULL; current = current->get_next())
			{
				if (current->get_cusp_number() != basepoint->get_cusp_number()) continue;
				if (current->get_temp() != -2) current->set_temp(-1);  // Leave -2's in as this longitude was separating.
				for (int i = 0; i < 4; i++)
				{
					current->set_peripheral_curves(longitude, i, 0);
					current->set_peripheral_curves(meridian, i, 0);
				}
			}
			continue;
		}
		
		// Flow meridian backwards.
		for (tetra *current = end_basepoint; current != start_basepoint; )
			for (int i = 0; i < 3; i++)
			{
				tetra *adjacent = current->get_gluedto(i);
				if (adjacent->get_temp() != (current->get_temp() - 1)) continue;
				
				current->set_peripheral_curves(meridian, i, 1);
				back_dir = (current->get_gluing(i))[i];
				adjacent->set_peripheral_curves(meridian, back_dir, -1);
				current = adjacent;
				break;
			}
		
		// Clear the temp data now that we're done.
		for (tetra *current = capoff_tetra; current != NULL; current = current->get_next())
			if (current->get_cusp_number() == basepoint->get_cusp_number())
				current->set_temp(-2);
		
		// If the manifold is a splitting we interchange the longitude and meridian. In order
		// to maintain the orientation convention, we flip the orientation of the meridian.
		if (this->get_manifold_type() == splitting)
			for (tetra *current = capoff_tetra; current != NULL; current = current->get_next())
				if (current->get_cusp_number() == basepoint->get_cusp_number())
					for (int i = 0; i < 3; i++)
					{
						int temp = current->get_peripheral_curves(longitude, i);
						current->set_peripheral_curves(longitude, i, current->get_peripheral_curves(meridian, i));
						current->set_peripheral_curves(meridian, i, -temp);
					}
	}
	
	// Now we repeat the whole process filling in the cusps that come from drillings.
	// Here the longitude is horizontal while the meridian goes up, around, down and back.
	for (tetra *basepoint = capoff_tetra; basepoint != NULL; basepoint = basepoint->get_next())
	{
		// Non-toroidal cusps have cusp number -1; avoid them.
		if ((basepoint->get_temp() != -1) || (basepoint->get_cusp_number() == -1)) continue;
		
		// We look for an even more specific type of basepoint.
		// To understand this, see the diagram of the cube.
		// 
		if (((basepoint->get_gluedto(3))->get_category() != gadget_left) || 
			((basepoint->get_gluedto(3))->get_position() != low) || 
			((basepoint->get_gluedto(3))->get_side() != right) ) continue;
		
		// Don't use basepoints that are glued to the end of rectangles (check for adjacent gadget_pups).
		bool good = true;
		for (int i = 0; i < 3; i++)
			if (((basepoint->get_gluedto(i))->get_gluedto(3))->get_category() == gadget_pup)
				good = false;
		
		if (!good) continue;
		
		// Now we work out the meridian starting from this basepoint.
		int back_dir = 0;
		bool upright = (basepoint->get_gluing(3)[3] == 2);  // Determine if the cube we attached to was a plus cube.
		int movements[4] = {3, upright ? 2 : 0, 1, 3};  // Array of movement directions.
		
		perm mount_to_basepoint = basepoint->get_gluing(3).inverse();
		tetra *current = basepoint;
		for (int i = 0; i < 4; i++)
		{
			int real_movement = (current->get_gluing(3).inverse())[movements[i]];
			current->set_temp(-2);
			current->set_peripheral_curves(meridian, real_movement, -1);
			back_dir = (current->get_gluing(real_movement))[real_movement];
			current = current->get_gluedto(real_movement);
			current->set_peripheral_curves(meridian, back_dir, 1);
		}
		if (current != basepoint) output_error("Misaligned meridian on a drilling.");
		
		// Now work out the longitude.
		// We look for a start and end on opposite sides of the meridian.
		
		int start_basepoint_dir = upright ? mount_to_basepoint[0] : mount_to_basepoint[2];
		int end_basepoint_dir = upright ? mount_to_basepoint[1] : mount_to_basepoint[0];
		
		tetra *start_basepoint = basepoint->get_gluedto(start_basepoint_dir);
		tetra *end_basepoint = basepoint->get_gluedto(end_basepoint_dir);
		
		// Start the longitude information.
		basepoint->set_peripheral_curves(longitude, start_basepoint_dir, -1);
		basepoint->set_peripheral_curves(longitude, end_basepoint_dir, 1);
		back_dir = (basepoint->get_gluing(end_basepoint_dir))[end_basepoint_dir];
		end_basepoint->set_peripheral_curves(longitude, back_dir, -1);
		back_dir = (basepoint->get_gluing(start_basepoint_dir))[start_basepoint_dir];
		start_basepoint->set_peripheral_curves(longitude, back_dir, 1);
		
		// Now find a path from start to end without crossing the meridian.
		// Remember, ones in the meridian have temp == -2.
		
		// Flow distance forwards.
		int old_start_basepoint_temp = start_basepoint->get_temp();
		start_basepoint->set_temp(0);  // Seed flow at start_basepoint.
		int old_end_basepoint_temp = end_basepoint->get_temp();
		end_basepoint->set_temp(-1);  // Better allow flow into end_basepoint.
		
		std::queue<tetra *> tetra_list;
		tetra_list.push(start_basepoint);
		while ((end_basepoint->get_temp() == -1) && !(tetra_list.empty()))
		{
			tetra *current = tetra_list.front();
			tetra_list.pop();
			for (int i = 0; i < 3; i++)
			{
				tetra *adjacent = current->get_gluedto(i);
				if (adjacent->get_temp() == -1)
				{
					adjacent->set_temp(current->get_temp() + 1);
					tetra_list.push(adjacent);
				}
			}
		}
		
		if (end_basepoint->get_temp() == -1)  // If the meridian was separating then clean up.
		{
			output_debugging("clean", 3);
			start_basepoint->set_temp(old_start_basepoint_temp);
			end_basepoint->set_temp(old_end_basepoint_temp);
			for (tetra *current = capoff_tetra; current != NULL; current = current->get_next())
			{
				if (current->get_cusp_number() != basepoint->get_cusp_number()) continue;
				if (current->get_temp() != -2) current->set_temp(-1);  // Leave -2's in as this meridian was separating.
				for (int i = 0; i < 4; i++)
				{
					current->set_peripheral_curves(longitude, i, 0);
					current->set_peripheral_curves(meridian, i, 0);
				}
			}
			continue;
		}
		
		// Flow longitude backwards.
		for (tetra *current = end_basepoint, *adjacent = NULL; current != start_basepoint; current = adjacent)
		{
			for (int i = 0; i < 3; i++)
			{
				adjacent = current->get_gluedto(i);
				if (adjacent->get_temp() != (current->get_temp() - 1)) continue;
				
				current->set_peripheral_curves(longitude, i, 1);
				back_dir = (current->get_gluing(i))[i];
				adjacent->set_peripheral_curves(longitude, back_dir, -1);
				break;
			}
		}
		
		// Clear the temp data now that we're done.
		for (tetra *current = capoff_tetra; current != NULL; current = current->get_next())
			if (current->get_cusp_number() == basepoint->get_cusp_number())
				current->set_temp(-2);
	}
	
	return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rsi, %r12
movq %rdi, %r14
leaq 0x128(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x534d(%rip), %rsi      # 0x17835
leaq 0x5349(%rip), %rdx      # 0x17838
leaq 0x118(%rsp), %rbx
movq %rbx, %rdi
callq 0x892e
movq %rbx, %rdi
movl $0x2, %esi
callq 0x4229
movq 0x118(%rsp), %rdi
cmpq %r15, %rdi
je 0x12529
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x3220
movq %r12, 0x68(%rsp)
testq %r12, %r12
je 0x12e81
cmpq $0x0, 0x8(%r14)
je 0x12e81
movq 0x68(%rsp), %r13
movq %r13, %rax
movl $0xffffffff, 0xb8(%rax) # imm = 0xFFFFFFFF
movq (%rax), %rax
testq %rax, %rax
jne 0x1254a
leaq 0x10(%rsp), %r15
leaq 0xb8(%rsp), %rbp
movq %r13, %rbx
cmpl $-0x1, 0xb8(%rbx)
je 0x12582
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x1256c
jmp 0x129a7
cmpl $-0x1, 0xb4(%rbx)
je 0x12575
movl 0x90(%rbx), %eax
cmpl 0x38(%r14), %eax
jne 0x12575
xorl %r12d, %r12d
movq 0x10(%rbx,%r12,8), %rcx
cmpl %eax, 0x90(%rcx)
jne 0x125b6
incq %r12
cmpq $0x3, %r12
jne 0x1259a
movl $0x3, %r12d
leal 0x2(%r12), %eax
movq %rax, %rcx
movl $0xaaaaaaab, %edx       # imm = 0xAAAAAAAB
imulq %rdx, %rcx
shrq $0x21, %rcx
leal (%rcx,%rcx,2), %ecx
subl %ecx, %eax
movq %rbx, %rdx
xorl %ecx, %ecx
movl $0xfffffffe, 0xb8(%rdx) # imm = 0xFFFFFFFE
movl 0x38(%r14), %esi
movl %eax, %r8d
shlq $0x2, %r8
xorl %edi, %edi
cmpq %rdi, %r8
je 0x125fe
movq 0x10(%rdx,%rdi,2), %rcx
cmpl %esi, 0x90(%rcx)
je 0x1260a
addq $0x4, %rdi
cmpq $0xc, %rdi
jne 0x125ec
jmp 0x1262f
movups 0x30(%rdx,%rdi,4), %xmm0
movaps %xmm0, 0x10(%rsp)
movslq 0x10(%rsp,%rdi), %rax
movl $0xffffffff, 0x94(%rdx,%rdi) # imm = 0xFFFFFFFF
movl $0x1, 0x94(%rcx,%rax,4)
movq %rcx, %rdx
cmpq %rbx, %rcx
jne 0x125d5
movq %rbx, %rdi
callq 0x12417
movl %r12d, %ecx
movq 0x10(%rbx,%rcx,8), %rdx
movq %rdx, 0x70(%rsp)
cltq
movq 0x10(%rbx,%rax,8), %r13
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl %edi, 0xa4(%rbx,%rcx,4)
movl $0x1, %r8d
movl %r8d, 0xa4(%rbx,%rax,4)
movq %rax, %rsi
shlq $0x4, %rsi
movups 0x30(%rbx,%rsi), %xmm0
movaps %xmm0, 0x10(%rsp)
movslq 0x10(%rsp,%rax,4), %rax
movl %edi, 0xa4(%r13,%rax,4)
movq %rcx, %rax
shlq $0x4, %rax
movups 0x30(%rbx,%rax), %xmm0
movaps %xmm0, 0x10(%rsp)
movslq 0x10(%rsp,%rcx,4), %rax
movl %r8d, 0xa4(%rdx,%rax,4)
movl 0xb8(%rdx), %eax
movl %eax, 0xc(%rsp)
movl $0x0, 0xb8(%rdx)
movl 0xb8(%r13), %eax
movl %eax, 0x8(%rsp)
movl %edi, 0xb8(%r13)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movq %r15, %rdi
xorl %esi, %esi
callq 0x13fce
movq 0x40(%rsp), %rax
movq 0x50(%rsp), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x12718
movq 0x70(%rsp), %rcx
movq %rcx, (%rax)
addq $0x8, 0x40(%rsp)
jmp 0x12725
movq %r15, %rdi
leaq 0x70(%rsp), %rsi
callq 0x14144
cmpl $-0x1, 0xb8(%r13)
jne 0x12806
movq 0x20(%rsp), %rax
cmpq %rax, 0x40(%rsp)
je 0x128e6
movq (%rax), %r12
movq 0x30(%rsp), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x1275a
addq $0x8, %rax
jmp 0x1278c
movq 0x28(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x3220
movq 0x38(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x38(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
leaq 0x200(%rax), %rcx
movq %rcx, 0x30(%rsp)
movq %rax, 0x20(%rsp)
xorl %ebp, %ebp
movq 0x10(%r12,%rbp,8), %rax
movq %rax, 0x90(%rsp)
cmpl $-0x1, 0xb8(%rax)
jne 0x127e7
movl 0xb8(%r12), %ecx
incl %ecx
movl %ecx, 0xb8(%rax)
movq 0x40(%rsp), %rcx
movq 0x50(%rsp), %rdx
addq $-0x8, %rdx
cmpq %rdx, %rcx
je 0x127d7
movq %rax, (%rcx)
addq $0x8, 0x40(%rsp)
jmp 0x127e7
movq %r15, %rdi
leaq 0x90(%rsp), %rsi
callq 0x14144
incq %rbp
cmpq $0x3, %rbp
jne 0x12793
cmpl $-0x1, 0xb8(%r13)
leaq 0xb8(%rsp), %rbp
je 0x12733
movq 0x70(%rsp), %rax
cmpq %rax, %r13
je 0x1286c
movl 0xb8(%r13), %edx
decl %edx
xorl %ecx, %ecx
movq 0x10(%r13,%rcx,2), %rsi
cmpl %edx, 0xb8(%rsi)
je 0x12837
addq $0x4, %rcx
cmpq $0xc, %rcx
jne 0x1281b
movq %r13, %rsi
jmp 0x12867
movl $0x1, 0xa4(%r13,%rcx)
movups 0x30(%r13,%rcx,4), %xmm0
movaps %xmm0, 0x90(%rsp)
movslq 0x90(%rsp,%rcx), %rcx
movl $0xffffffff, 0xa4(%rsi,%rcx,4) # imm = 0xFFFFFFFF
movq %rsi, %r13
cmpq %rax, %rsi
jne 0x12810
movl 0xb4(%rbx), %eax
movq 0x68(%rsp), %r13
movq %r13, %rcx
cmpl %eax, 0xb4(%rcx)
jne 0x1288c
movl $0xfffffffe, 0xb8(%rcx) # imm = 0xFFFFFFFE
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0x1287a
cmpl $0x0, 0x10(%r14)
movq %r13, %rax
jne 0x1299a
movl 0xb4(%rax), %ecx
cmpl 0xb4(%rbx), %ecx
jne 0x128d9
xorl %ecx, %ecx
movl 0xa4(%rax,%rcx,4), %edx
xorl %esi, %esi
subl 0x94(%rax,%rcx,4), %esi
movl %edx, 0x94(%rax,%rcx,4)
movl %esi, 0xa4(%rax,%rcx,4)
incq %rcx
cmpq $0x3, %rcx
jne 0x128b2
movq (%rax), %rax
testq %rax, %rax
jne 0x128a2
jmp 0x1299a
leaq 0xc8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq %rbp, %rdi
leaq 0x4f39(%rip), %rsi      # 0x17839
leaq 0x4f37(%rip), %rdx      # 0x1783e
callq 0x892e
movq %rbp, %rdi
movl $0x3, %esi
callq 0x4229
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x1293e
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x3220
movq 0x70(%rsp), %rax
movl 0xc(%rsp), %ecx
movl %ecx, 0xb8(%rax)
movl 0x8(%rsp), %eax
movl %eax, 0xb8(%r13)
movq 0x68(%rsp), %r13
movq %r13, %rax
movl 0xb4(%rax), %ecx
cmpl 0xb4(%rbx), %ecx
jne 0x12992
cmpl $-0x2, 0xb8(%rax)
je 0x12981
movl $0xffffffff, 0xb8(%rax) # imm = 0xFFFFFFFF
xorps %xmm0, %xmm0
movups %xmm0, 0xa4(%rax)
movups %xmm0, 0x94(%rax)
movq (%rax), %rax
testq %rax, %rax
jne 0x12960
movq %r15, %rdi
callq 0x13b9c
jmp 0x12575
movabsq $0x300000001, %rsi      # imm = 0x300000001
leaq 0x10(%rsp), %r14
leaq 0xa0(%rsp), %rbp
cmpl $-0x1, 0xb8(%r13)
je 0x129d6
movq (%r13), %r13
testq %r13, %r13
jne 0x129be
jmp 0x12e81
cmpl $-0x1, 0xb4(%r13)
je 0x129c8
movq 0x28(%r13), %rax
cmpl $0x4, 0x70(%rax)
jne 0x129c8
cmpl $0x2, 0x74(%rax)
jne 0x129c8
cmpl $0x1, 0x78(%rax)
jne 0x129c8
movb $0x1, %al
movl $0x2, %ecx
movq (%r13,%rcx,8), %rdx
movq 0x28(%rdx), %rdx
cmpl $0x6, 0x70(%rdx)
setne %dl
andb %dl, %al
incq %rcx
cmpq $0x5, %rcx
jne 0x129fd
testb %al, %al
je 0x129c8
movl 0x6c(%r13), %ebx
xorl %eax, %eax
cmpl $0x2, %ebx
sete %al
movl $0x3, 0x90(%rsp)
addl %eax, %eax
movl %eax, 0x94(%rsp)
movq %rsi, 0x98(%rsp)
movups 0x60(%r13), %xmm0
movaps %xmm0, 0x10(%rsp)
movaps 0x4a5b(%rip), %xmm0     # 0x174b0
movaps %xmm0, 0x70(%rsp)
xorl %eax, %eax
movslq 0x10(%rsp,%rax,4), %rcx
movl %eax, 0x70(%rsp,%rcx,4)
incq %rax
cmpq $0x4, %rax
jne 0x12a5c
xorl %ecx, %ecx
movq %r13, %rax
movups 0x60(%rax), %xmm0
movaps %xmm0, 0xa0(%rsp)
movaps 0x4a2a(%rip), %xmm0     # 0x174b0
movaps %xmm0, 0x10(%rsp)
xorl %edx, %edx
movslq 0xa0(%rsp,%rdx,4), %rsi
movl %edx, 0x10(%rsp,%rsi,4)
incq %rdx
cmpq $0x4, %rdx
jne 0x12a8d
movslq 0x90(%rsp,%rcx,4), %rdx
movslq 0x10(%rsp,%rdx,4), %rdx
movl $0xfffffffe, 0xb8(%rax) # imm = 0xFFFFFFFE
movl $0xffffffff, 0xa4(%rax,%rdx,4) # imm = 0xFFFFFFFF
movq %rdx, %rsi
shlq $0x4, %rsi
movups 0x30(%rax,%rsi), %xmm0
movaps %xmm0, 0x10(%rsp)
movslq 0x10(%rsp,%rdx,4), %rsi
movq 0x10(%rax,%rdx,8), %rax
movl $0x1, 0xa4(%rax,%rsi,4)
incq %rcx
cmpq $0x4, %rcx
jne 0x12a73
cmpq %r13, %rax
je 0x12b53
leaq 0x108(%rsp), %rax
movq %rax, 0xf8(%rsp)
leaq 0xf8(%rsp), %r15
movq %r15, %rdi
leaq 0x4d25(%rip), %rsi      # 0x1783f
leaq 0x4d40(%rip), %rdx      # 0x17861
callq 0x892e
movq %r15, %rdi
callq 0x43b0
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x12b53
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x3220
cmpl $0x2, %ebx
movl 0x70(%rsp), %eax
movl 0x78(%rsp), %ecx
cmovel %eax, %ecx
leaq 0x30(%r13), %rdx
cmovel 0x74(%rsp), %eax
movslq %ecx, %rcx
movq 0x10(%r13,%rcx,8), %rsi
movq %rsi, 0x88(%rsp)
cltq
movq 0x10(%r13,%rax,8), %rbx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movl %r8d, 0x94(%r13,%rcx,4)
movl $0x1, %r9d
movl %r9d, 0x94(%r13,%rax,4)
movq %rax, %rdi
shlq $0x4, %rdi
movups (%rdx,%rdi), %xmm0
movaps %xmm0, 0x10(%rsp)
movslq 0x10(%rsp,%rax,4), %rax
movl %r8d, 0x94(%rbx,%rax,4)
movq %rcx, %rax
shlq $0x4, %rax
movups (%rdx,%rax), %xmm0
movaps %xmm0, 0x10(%rsp)
movslq 0x10(%rsp,%rcx,4), %rax
movl %r9d, 0x94(%rsi,%rax,4)
movl 0xb8(%rsi), %eax
movl %eax, 0xc(%rsp)
movl $0x0, 0xb8(%rsi)
movl 0xb8(%rbx), %eax
movl %eax, 0x8(%rsp)
movl %r8d, 0xb8(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movq %r14, %rdi
xorl %esi, %esi
callq 0x13fce
movq 0x40(%rsp), %rax
movq 0x50(%rsp), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x12c48
movq 0x88(%rsp), %rcx
movq %rcx, (%rax)
addq $0x8, 0x40(%rsp)
jmp 0x12c58
movq %r14, %rdi
leaq 0x88(%rsp), %rsi
callq 0x14144
cmpl $-0x1, 0xb8(%rbx)
jne 0x12d23
movq 0x20(%rsp), %rax
cmpq %rax, 0x40(%rsp)
je 0x12dc0
movq (%rax), %r12
movq 0x30(%rsp), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x12c8c
addq $0x8, %rax
jmp 0x12cbe
movq 0x28(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x3220
movq 0x38(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x38(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
leaq 0x200(%rax), %rcx
movq %rcx, 0x30(%rsp)
movq %rax, 0x20(%rsp)
xorl %r15d, %r15d
movq 0x10(%r12,%r15,8), %rax
movq %rax, 0xa0(%rsp)
cmpl $-0x1, 0xb8(%rax)
jne 0x12d15
movl 0xb8(%r12), %ecx
incl %ecx
movl %ecx, 0xb8(%rax)
movq 0x40(%rsp), %rcx
movq 0x50(%rsp), %rdx
addq $-0x8, %rdx
cmpq %rdx, %rcx
je 0x12d0a
movq %rax, (%rcx)
addq $0x8, 0x40(%rsp)
jmp 0x12d15
movq %r14, %rdi
movq %rbp, %rsi
callq 0x14144
incq %r15
cmpq $0x3, %r15
jne 0x12cc6
jmp 0x12c58
movq 0x88(%rsp), %rax
cmpq %rax, %rbx
je 0x12d83
movq %rbx, %rcx
movl 0xb8(%rbx), %esi
decl %esi
xorl %edx, %edx
movq 0x10(%rcx,%rdx,2), %rbx
cmpl %esi, 0xb8(%rbx)
je 0x12d56
addq $0x4, %rdx
cmpq $0xc, %rdx
jne 0x12d3d
jmp 0x12d2b
movl $0x1, 0x94(%rcx,%rdx)
movups 0x30(%rcx,%rdx,4), %xmm0
movaps %xmm0, 0xa0(%rsp)
movslq 0xa0(%rsp,%rdx), %rcx
movl $0xffffffff, 0x94(%rbx,%rcx,4) # imm = 0xFFFFFFFF
jmp 0x12d2b
movl 0xb4(%r13), %eax
movq 0x68(%rsp), %rcx
cmpl %eax, 0xb4(%rcx)
jne 0x12da1
movl $0xfffffffe, 0xb8(%rcx) # imm = 0xFFFFFFFE
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0x12d8f
movq %r14, %rdi
callq 0x13b9c
movabsq $0x300000001, %rsi      # imm = 0x300000001
jmp 0x129c8
leaq 0xe8(%rsp), %rax
movq %rax, 0xd8(%rsp)
leaq 0xd8(%rsp), %r15
movq %r15, %rdi
leaq 0x4a57(%rip), %rsi      # 0x17839
leaq 0x4a55(%rip), %rdx      # 0x1783e
callq 0x892e
movq %r15, %rdi
movl $0x3, %esi
callq 0x4229
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x12e20
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x3220
movq 0x88(%rsp), %rax
movl 0xc(%rsp), %ecx
movl %ecx, 0xb8(%rax)
movl 0x8(%rsp), %eax
movl %eax, 0xb8(%rbx)
movq 0x68(%rsp), %rax
movl 0xb4(%rax), %ecx
cmpl 0xb4(%r13), %ecx
jne 0x12e74
cmpl $-0x2, 0xb8(%rax)
je 0x12e63
movl $0xffffffff, 0xb8(%rax) # imm = 0xFFFFFFFF
xorps %xmm0, %xmm0
movups %xmm0, 0xa4(%rax)
movups %xmm0, 0x94(%rax)
movq (%rax), %rax
testq %rax, %rax
jne 0x12e41
jmp 0x12da9
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x12f39
movq 0xe8(%rsp), %rsi
jmp 0x12f04
jmp 0x12f36
jmp 0x12f36
movq %rax, %r14
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x12f43
movq 0x108(%rsp), %rsi
jmp 0x12f2a
movq %rax, %r14
jmp 0x12f43
movq %rax, %r14
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x12f39
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x3220
jmp 0x12f39
jmp 0x12f36
jmp 0x12f36
movq %rax, %r14
movq 0x118(%rsp), %rdi
cmpq %r15, %rdi
je 0x12f43
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x3220
jmp 0x12f43
jmp 0x12f36
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x13b9c
movq %r14, %rdi
callq 0x33e0
nop