// File: /workspace/github_cpp_makefile_star2_O1/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 $0x128, %rsp            # imm = 0x128
movq %rsi, %r12
movq %rdi, %r14
leaq 0x118(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x5435(%rip), %rsi      # 0x177f5
leaq 0x5431(%rip), %rdx      # 0x177f8
leaq 0x108(%rsp), %rbx
movq %rbx, %rdi
callq 0x86fe
movq %rbx, %rdi
movl $0x2, %esi
callq 0x4209
movq 0x108(%rsp), %rdi
cmpq %r15, %rdi
je 0x12401
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x3220
movq %r12, 0x8(%rsp)
testq %r12, %r12
je 0x12d75
cmpq $0x0, 0x8(%r14)
je 0x12d75
movq 0x8(%rsp), %rcx
movq %rcx, %rax
movl $0xffffffff, 0xb8(%rax) # imm = 0xFFFFFFFF
movq (%rax), %rax
testq %rax, %rax
jne 0x12422
testq %rcx, %rcx
je 0x12d75
leaq 0x10(%rsp), %r15
movq 0x8(%rsp), %r13
movq %r13, %rbx
cmpl $-0x1, 0xb8(%rbx)
je 0x12460
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x1244a
jmp 0x12897
cmpl $-0x1, 0xb4(%rbx)
je 0x12453
movl 0x38(%r14), %eax
cmpl %eax, 0x90(%rbx)
jne 0x12453
xorl %r12d, %r12d
movq 0x10(%rbx,%r12,8), %rcx
cmpl %eax, 0x90(%rcx)
jne 0x12494
incq %r12
cmpq $0x3, %r12
jne 0x12478
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 0x124dc
movq 0x10(%rdx,%rdi,2), %rcx
cmpl %esi, 0x90(%rcx)
je 0x124e8
addq $0x4, %rdi
cmpq $0xc, %rdi
jne 0x124ca
jmp 0x1250d
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 0x124b3
movq %rbx, %rdi
callq 0x122d7
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, 0x4(%rsp)
movl $0x0, 0xb8(%rdx)
movl 0xb8(%r13), %eax
movl %eax, (%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 0x13f08
movq 0x40(%rsp), %rax
movq 0x50(%rsp), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x125f5
movq 0x70(%rsp), %rcx
movq %rcx, (%rax)
addq $0x8, 0x40(%rsp)
jmp 0x12602
movq %r15, %rdi
leaq 0x70(%rsp), %rsi
callq 0x1407e
cmpl $-0x1, 0xb8(%r13)
sete %cl
jne 0x1279d
movq 0x20(%rsp), %rax
cmpq %rax, 0x40(%rsp)
je 0x126d5
movq (%rax), %r12
movq 0x30(%rsp), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x1263a
addq $0x8, %rax
jmp 0x1266c
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, 0x80(%rsp)
cmpl $-0x1, 0xb8(%rax)
jne 0x126c7
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 0x126b7
movq %rax, (%rcx)
addq $0x8, 0x40(%rsp)
jmp 0x126c7
movq %r15, %rdi
leaq 0x80(%rsp), %rsi
callq 0x1407e
incq %rbp
cmpq $0x3, %rbp
jne 0x12673
jmp 0x12602
testb %cl, %cl
je 0x1279d
leaq 0xf8(%rsp), %rax
movq %rax, 0xe8(%rsp)
leaq 0xe8(%rsp), %r12
movq %r12, %rdi
leaq 0x50fa(%rip), %rsi      # 0x177f9
leaq 0x50f8(%rip), %rdx      # 0x177fe
callq 0x86fe
movq %r12, %rdi
movl $0x3, %esi
callq 0x4209
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x1273d
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x3220
movq 0x70(%rsp), %rax
movl 0x4(%rsp), %ecx
movl %ecx, 0xb8(%rax)
movl (%rsp), %eax
movl %eax, 0xb8(%r13)
movq 0x8(%rsp), %r13
movq %r13, %rax
movl 0xb4(%rax), %ecx
cmpl 0xb4(%rbx), %ecx
jne 0x12790
cmpl $-0x2, 0xb8(%rax)
je 0x1277f
movl $0xffffffff, 0xb8(%rax) # imm = 0xFFFFFFFF
xorps %xmm0, %xmm0
movups %xmm0, 0xa4(%rax)
movups %xmm0, 0x94(%rax)
movq (%rax), %rax
testq %rax, %rax
jne 0x1275e
jmp 0x1288a
movq 0x70(%rsp), %rax
cmpq %rax, %r13
je 0x12819
xorl %ecx, %ecx
movq 0x10(%r13,%rcx,8), %rdi
movl 0xb8(%rdi), %edx
movl 0xb8(%r13), %esi
decl %esi
cmpl %esi, %edx
jne 0x127f9
movl $0x1, 0xa4(%r13,%rcx,4)
movq %rcx, %r8
shlq $0x4, %r8
movups 0x30(%r13,%r8), %xmm0
movaps %xmm0, 0x80(%rsp)
movslq 0x80(%rsp,%rcx,4), %r8
movl $0xffffffff, 0xa4(%rdi,%r8,4) # imm = 0xFFFFFFFF
movq %rdi, %r13
cmpl %esi, %edx
setne %dl
cmpq $0x2, %rcx
leaq 0x1(%rcx), %rcx
setb %sil
testb %sil, %dl
jne 0x127a9
movl $0x0, %ecx
cmpq %rax, %r13
jne 0x127a9
movl 0xb4(%rbx), %eax
movq 0x8(%rsp), %r13
movq %r13, %rcx
cmpl %eax, 0xb4(%rcx)
jne 0x12839
movl $0xfffffffe, 0xb8(%rcx) # imm = 0xFFFFFFFE
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0x12827
cmpl $0x0, 0x10(%r14)
movq %r13, %rax
jne 0x1288a
movl 0xb4(%rax), %ecx
cmpl 0xb4(%rbx), %ecx
jne 0x12882
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 0x1285b
movq (%rax), %rax
testq %rax, %rax
jne 0x1284b
movq %r15, %rdi
callq 0x13ac8
jmp 0x12453
xorl %ebp, %ebp
movabsq $0x300000001, %rsi      # imm = 0x300000001
leaq 0x10(%rsp), %r14
cmpl $-0x1, 0xb8(%r13)
je 0x128c0
movq (%r13), %r13
testq %r13, %r13
jne 0x128a8
jmp 0x12d75
cmpl $-0x1, 0xb4(%r13)
je 0x128b2
movq 0x28(%r13), %rax
cmpl $0x4, 0x70(%rax)
jne 0x128b2
cmpl $0x2, 0x74(%rax)
jne 0x128b2
cmpl $0x1, 0x78(%rax)
jne 0x128b2
movb $0x1, %al
movl $0x2, %ecx
movq (%r13,%rcx,8), %rdx
movq 0x28(%rdx), %rdx
cmpl $0x6, 0x70(%rdx)
movzbl %al, %eax
cmovel %ebp, %eax
incq %rcx
cmpq $0x5, %rcx
jne 0x128e7
testb $0x1, %al
je 0x128b2
movl 0x6c(%r13), %ebx
xorl %eax, %eax
cmpl $0x2, %ebx
sete %al
movl $0x3, 0x80(%rsp)
addl %eax, %eax
movl %eax, 0x84(%rsp)
movq %rsi, 0x88(%rsp)
movups 0x60(%r13), %xmm0
movaps %xmm0, 0x10(%rsp)
xorl %eax, %eax
movl %eax, 0x70(%rsp,%rax,4)
incq %rax
cmpq $0x4, %rax
jne 0x1293b
xorl %eax, %eax
movslq 0x10(%rsp,%rax,4), %rcx
movl %eax, 0x70(%rsp,%rcx,4)
incq %rax
cmpq $0x4, %rax
jne 0x1294a
xorl %ecx, %ecx
movq %r13, %rax
movups 0x60(%rax), %xmm0
movaps %xmm0, 0x90(%rsp)
xorl %edx, %edx
movl %edx, 0x10(%rsp,%rdx,4)
incq %rdx
cmpq $0x4, %rdx
jne 0x1296f
xorl %edx, %edx
movslq 0x90(%rsp,%rdx,4), %rsi
movl %edx, 0x10(%rsp,%rsi,4)
incq %rdx
cmpq $0x4, %rdx
jne 0x1297e
movslq 0x80(%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 0x12961
cmpq %r13, %rax
je 0x12a48
leaq 0xd8(%rsp), %rax
movq %rax, 0xc8(%rsp)
leaq 0xc8(%rsp), %r15
movq %r15, %rdi
leaq 0x4df0(%rip), %rsi      # 0x177ff
leaq 0x4e0b(%rip), %rdx      # 0x17821
callq 0x86fe
movq %r15, %rdi
callq 0x4397
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x12a48
movq 0xd8(%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, 0x68(%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, 0x4(%rsp)
movl $0x0, 0xb8(%rsi)
movl 0xb8(%rbx), %eax
movl %eax, (%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 0x13f08
movq 0x40(%rsp), %rax
movq 0x50(%rsp), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x12b36
movq 0x68(%rsp), %rcx
movq %rcx, (%rax)
addq $0x8, 0x40(%rsp)
jmp 0x12b43
movq %r14, %rdi
leaq 0x68(%rsp), %rsi
callq 0x1407e
cmpl $-0x1, 0xb8(%rbx)
sete %cl
jne 0x12cdb
movq 0x20(%rsp), %rax
cmpq %rax, 0x40(%rsp)
je 0x12c16
movq (%rax), %r12
movq 0x30(%rsp), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x12b7a
addq $0x8, %rax
jmp 0x12bac
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, 0x90(%rsp)
cmpl $-0x1, 0xb8(%rax)
jne 0x12c08
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 0x12bf8
movq %rax, (%rcx)
addq $0x8, 0x40(%rsp)
jmp 0x12c08
movq %r14, %rdi
leaq 0x90(%rsp), %rsi
callq 0x1407e
incq %r15
cmpq $0x3, %r15
jne 0x12bb4
jmp 0x12b43
testb %cl, %cl
je 0x12cdb
leaq 0xb8(%rsp), %rax
movq %rax, 0xa8(%rsp)
leaq 0xa8(%rsp), %r15
movq %r15, %rdi
leaq 0x4bb9(%rip), %rsi      # 0x177f9
leaq 0x4bb7(%rip), %rdx      # 0x177fe
callq 0x86fe
movq %r15, %rdi
movl $0x3, %esi
callq 0x4209
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x12c7e
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x3220
movq 0x68(%rsp), %rax
movl 0x4(%rsp), %ecx
movl %ecx, 0xb8(%rax)
movl (%rsp), %eax
movl %eax, 0xb8(%rbx)
movq 0x8(%rsp), %rax
movl 0xb4(%rax), %ecx
cmpl 0xb4(%r13), %ecx
jne 0x12cce
cmpl $-0x2, 0xb8(%rax)
je 0x12cbd
movl $0xffffffff, 0xb8(%rax) # imm = 0xFFFFFFFF
xorps %xmm0, %xmm0
movups %xmm0, 0xa4(%rax)
movups %xmm0, 0x94(%rax)
movq (%rax), %rax
testq %rax, %rax
jne 0x12c9b
jmp 0x12d5e
movq 0x68(%rsp), %rax
cmpq %rax, %rbx
je 0x12d38
movq %rbx, %rcx
movl 0xb8(%rbx), %esi
decl %esi
xorl %edx, %edx
movq 0x10(%rcx,%rdx,2), %rbx
cmpl %esi, 0xb8(%rbx)
je 0x12d0b
addq $0x4, %rdx
cmpq $0xc, %rdx
jne 0x12cf2
jmp 0x12ce0
movl $0x1, 0x94(%rcx,%rdx)
movups 0x30(%rcx,%rdx,4), %xmm0
movaps %xmm0, 0x90(%rsp)
movslq 0x90(%rsp,%rdx), %rcx
movl $0xffffffff, 0x94(%rbx,%rcx,4) # imm = 0xFFFFFFFF
jmp 0x12ce0
movl 0xb4(%r13), %eax
movq 0x8(%rsp), %rcx
cmpl %eax, 0xb4(%rcx)
jne 0x12d56
movl $0xfffffffe, 0xb8(%rcx) # imm = 0xFFFFFFFE
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0x12d44
movq %r14, %rdi
callq 0x13ac8
movabsq $0x300000001, %rsi      # imm = 0x300000001
jmp 0x128b2
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x12e2d
movq 0xb8(%rsp), %rsi
jmp 0x12df8
jmp 0x12e2a
jmp 0x12e2a
movq %rax, %r14
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x12e37
movq 0xd8(%rsp), %rsi
jmp 0x12e1e
movq %rax, %r14
jmp 0x12e37
movq %rax, %r14
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x12e2d
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x3220
jmp 0x12e2d
jmp 0x12e2a
jmp 0x12e2a
movq %rax, %r14
movq 0x108(%rsp), %rdi
cmpq %r15, %rdi
je 0x12e37
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x3220
jmp 0x12e37
jmp 0x12e2a
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x13ac8
movq %r14, %rdi
callq 0x33e0
nop