// File: /workspace/github_cpp_makefile_star2_O2/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, %rbp
movq %rdi, (%rsp)
leaq 0x373e(%rip), %rsi      # 0x1178d
leaq 0xa8(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x3e82
leaq 0xa8(%rsp), %rdi
pushq $0x2
popq %rsi
callq 0x3d1a
leaq 0xa8(%rsp), %rdi
callq 0x3458
testq %rbp, %rbp
je 0xe7c2
movq (%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0xe7c2
movq %rbp, %rax
testq %rax, %rax
je 0xe0aa
orl $-0x1, 0xb8(%rax)
movq (%rax), %rax
jmp 0xe099
pushq $0x3
popq %r14
leaq 0x48(%rsp), %r15
movq %rbp, %r12
movq %rbp, 0x10(%rsp)
testq %r12, %r12
je 0xe410
cmpl $-0x1, 0xb8(%r12)
je 0xe0d5
movq (%r12), %r12
jmp 0xe0bb
cmpl $-0x1, 0xb4(%r12)
je 0xe0cf
movl 0x90(%r12), %eax
movq (%rsp), %rcx
cmpl 0x38(%rcx), %eax
jne 0xe0cf
xorl %ebx, %ebx
cmpq $0x3, %rbx
je 0xe10b
movq 0x10(%r12,%rbx,8), %rcx
cmpl %eax, 0x90(%rcx)
jne 0xe10e
incq %rbx
jmp 0xe0f3
movl %r14d, %ebx
leal 0x2(%rbx), %eax
xorl %edx, %edx
divl %r14d
xorl %r13d, %r13d
movq %r12, %rbp
movl %edx, %eax
cmpq %r12, %r13
je 0xe187
movl $0xfffffffe, 0xb8(%rbp) # imm = 0xFFFFFFFE
movq (%rsp), %rcx
movl 0x38(%rcx), %ecx
xorl %r14d, %r14d
cmpq $0x3, %r14
je 0xe155
cmpq %r14, %rax
je 0xe150
movq 0x10(%rbp,%r14,8), %r13
cmpl %ecx, 0x90(%r13)
je 0xe15a
incq %r14
jmp 0xe137
movq %r13, %rbp
jmp 0xe11e
movq %r15, %rdi
movq %rbp, %rsi
movl %r14d, %edx
callq 0xf05e
movslq 0x48(%rsp,%r14,4), %rdx
orl $-0x1, 0x94(%rbp,%r14,4)
movl $0x1, 0x94(%r13,%rdx,4)
movq %r13, %rbp
jmp 0xe11c
movq %r12, %rdi
callq 0xdf83
movl %ebx, %ebp
movq 0x10(%r12,%rbp,8), %rcx
movq %rcx, 0x38(%rsp)
movslq %eax, %r14
movq 0x10(%r12,%r14,8), %r13
orl $-0x1, 0xa4(%r12,%rbp,4)
pushq $0x1
popq %rax
movl %eax, 0xa4(%r12,%r14,4)
movq %r15, %rdi
movq %r12, %rsi
movl %r14d, %edx
callq 0xf05e
movslq 0x48(%rsp,%r14,4), %rax
orl $-0x1, 0xa4(%r13,%rax,4)
movq %r15, %rdi
movq %r12, %rsi
movl %ebx, %edx
callq 0xf05e
movslq 0x48(%rsp,%rbp,4), %rax
movq 0x38(%rsp), %rcx
pushq $0x1
popq %rdx
movl %edx, 0xa4(%rcx,%rax,4)
movl 0xb8(%rcx), %eax
movl %eax, 0xc(%rsp)
andl $0x0, 0xb8(%rcx)
movl 0xb8(%r13), %r14d
orl $-0x1, 0xb8(%r13)
movq %r15, %rdi
callq 0xf11e
movq %r15, %rdi
leaq 0x38(%rsp), %rsi
callq 0xf85e
cmpl $-0x1, 0xb8(%r13)
jne 0xe289
movq 0x58(%rsp), %rax
cmpq %rax, 0x78(%rsp)
je 0xe374
movq (%rax), %rbp
movq %r15, %rdi
callq 0xfa92
xorl %ebx, %ebx
cmpq $0x3, %rbx
je 0xe229
movq 0x10(%rbp,%rbx,8), %rax
movq %rax, 0x20(%rsp)
cmpl $-0x1, 0xb8(%rax)
jne 0xe284
movl 0xb8(%rbp), %ecx
incl %ecx
movl %ecx, 0xb8(%rax)
movq %r15, %rdi
leaq 0x20(%rsp), %rsi
callq 0xf85e
incq %rbx
jmp 0xe250
movq 0x10(%rsp), %rbp
movq 0x38(%rsp), %rax
cmpq %rax, %r13
je 0xe2ea
movl 0xb8(%r13), %ecx
decl %ecx
xorl %ebx, %ebx
cmpq $0x3, %rbx
je 0xe293
movq 0x10(%r13,%rbx,8), %r14
cmpl %ecx, 0xb8(%r14)
je 0xe2bc
incq %rbx
jmp 0xe2a3
movl $0x1, 0xa4(%r13,%rbx,4)
leaq 0x20(%rsp), %rdi
movq %r13, %rsi
movl %ebx, %edx
callq 0xf05e
movslq 0x20(%rsp,%rbx,4), %rax
orl $-0x1, 0xa4(%r14,%rax,4)
movq %r14, %r13
jmp 0xe28e
movq %rbp, %rax
pushq $0x3
popq %r14
testq %rax, %rax
je 0xe315
movl 0xb4(%rax), %ecx
cmpl 0xb4(%r12), %ecx
jne 0xe310
movl $0xfffffffe, 0xb8(%rax) # imm = 0xFFFFFFFE
movq (%rax), %rax
jmp 0xe2f1
movq (%rsp), %rax
cmpl $0x0, 0x10(%rax)
movq %rbp, %rax
jne 0xe367
jmp 0xe362
movl 0xb4(%rax), %ecx
cmpl 0xb4(%r12), %ecx
jne 0xe35f
xorl %ecx, %ecx
cmpq $0x3, %rcx
je 0xe35f
xorl %edx, %edx
subl 0x94(%rax,%rcx,4), %edx
movl 0xa4(%rax,%rcx,4), %esi
movl %esi, 0x94(%rax,%rcx,4)
movl %edx, 0xa4(%rax,%rcx,4)
incq %rcx
jmp 0xe336
movq (%rax), %rax
testq %rax, %rax
jne 0xe324
movq %r15, %rdi
callq 0xf158
jmp 0xe0cf
leaq 0x108(%rsp), %rbx
movq %rbx, %rdi
leaq 0x340b(%rip), %rsi      # 0x11791
leaq 0x20(%rsp), %rdx
callq 0x3e82
movq %rbx, %rdi
pushq $0x3
popq %rsi
callq 0x3d1a
movq 0x10(%rsp), %rbp
movq %rbx, %rdi
callq 0x3458
movq 0x38(%rsp), %rax
movl 0xc(%rsp), %ecx
movl %ecx, 0xb8(%rax)
movl %r14d, 0xb8(%r13)
movq %rbp, %rax
pushq $0x3
popq %r14
pushq $-0x10
popq %rdx
testq %rax, %rax
je 0xe367
movl 0xb4(%rax), %ecx
cmpl 0xb4(%r12), %ecx
jne 0xe40b
cmpl $-0x2, 0xb8(%rax)
je 0xe3ed
orl $-0x1, 0xb8(%rax)
movq %rdx, %rcx
testq %rcx, %rcx
je 0xe40b
andl $0x0, 0xa4(%rax,%rcx)
andl $0x0, 0xb4(%rax,%rcx)
addq $0x4, %rcx
jmp 0xe3f0
movq (%rax), %rax
jmp 0xe3c8
pushq $0x2
popq %rsi
leaq 0x48(%rsp), %r14
movabsq $0x300000001, %r15      # imm = 0x300000001
leaq 0x98(%rsp), %r13
movq %rbp, %rbx
testq %rbx, %rbx
je 0xe7c2
cmpl $-0x1, 0xb8(%rbx)
je 0xe444
movq (%rbx), %rbx
jmp 0xe42d
cmpl $-0x1, 0xb4(%rbx)
je 0xe43f
movq 0x28(%rbx), %rax
cmpl $0x4, 0x70(%rax)
jne 0xe43f
cmpl $0x2, 0x74(%rax)
jne 0xe43f
cmpl $0x1, 0x78(%rax)
jne 0xe43f
movb $0x1, %al
movq %rsi, %rcx
cmpq $0x5, %rcx
je 0xe484
movq (%rbx,%rcx,8), %rdx
movq 0x28(%rdx), %rdx
cmpl $0x6, 0x70(%rdx)
setne %dl
andb %dl, %al
incq %rcx
jmp 0xe468
testb $0x1, %al
je 0xe43f
leaq 0x60(%rbx), %rbp
movq %r14, %rdi
movq %rbp, %rsi
callq 0xa366
movl 0x54(%rsp), %ecx
xorl %eax, %eax
movl %ecx, (%rsp)
cmpl $0x2, %ecx
sete %al
movl $0x3, 0x20(%rsp)
addl %eax, %eax
movl %eax, 0x24(%rsp)
movq %r15, 0x28(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
callq 0xa366
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0xa396
xorl %r15d, %r15d
movq %rbx, %rbp
cmpq $0x4, %r15
je 0xe539
leaq 0x60(%rbp), %rsi
movq %r13, %rdi
callq 0xa366
movq %r14, %rdi
movq %r13, %rsi
callq 0xa396
movslq 0x20(%rsp,%r15,4), %rax
movslq 0x48(%rsp,%rax,4), %r12
movl $0xfffffffe, 0xb8(%rbp) # imm = 0xFFFFFFFE
orl $-0x1, 0xa4(%rbp,%r12,4)
movq %r14, %rdi
movq %rbp, %rsi
movl %r12d, %edx
callq 0xf05e
movslq 0x48(%rsp,%r12,4), %rax
movq 0x10(%rbp,%r12,8), %rbp
movl $0x1, 0xa4(%rbp,%rax,4)
incq %r15
jmp 0xe4d7
cmpq %rbx, %rbp
je 0xe568
leaq 0xe8(%rsp), %r15
movq %r15, %rdi
leaq 0x3247(%rip), %rsi      # 0x11797
movq %r14, %rdx
callq 0x3e82
movq %r15, %rdi
callq 0x3dec
movq %r15, %rdi
callq 0x3458
cmpl $0x2, (%rsp)
movl 0x38(%rsp), %eax
movl 0x40(%rsp), %ecx
cmovel %eax, %ecx
cmovel 0x3c(%rsp), %eax
movslq %ecx, %r12
movq 0x10(%rbx,%r12,8), %rcx
movq %rcx, 0x18(%rsp)
movslq %eax, %rbp
movq 0x10(%rbx,%rbp,8), %r15
orl $-0x1, 0x94(%rbx,%r12,4)
pushq $0x1
popq %rax
movl %eax, 0x94(%rbx,%rbp,4)
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0xf05e
movslq 0x48(%rsp,%rbp,4), %rax
orl $-0x1, 0x94(%r15,%rax,4)
movq %r14, %rdi
movq %rbx, %rsi
movl %r12d, %edx
callq 0xf05e
movslq 0x48(%rsp,%r12,4), %rax
movq 0x18(%rsp), %rcx
pushq $0x1
popq %rdx
movl %edx, 0x94(%rcx,%rax,4)
movl 0xb8(%rcx), %eax
movl %eax, (%rsp)
andl $0x0, 0xb8(%rcx)
movl 0xb8(%r15), %eax
movl %eax, 0xc(%rsp)
orl $-0x1, 0xb8(%r15)
movq %r14, %rdi
callq 0xf11e
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
callq 0xf85e
cmpl $-0x1, 0xb8(%r15)
jne 0xe67b
movq 0x58(%rsp), %rax
cmpq %rax, 0x78(%rsp)
je 0xe711
movq (%rax), %rbp
movq %r14, %rdi
callq 0xfa92
xorl %r12d, %r12d
cmpq $0x3, %r12
je 0xe619
movq 0x10(%rbp,%r12,8), %rax
movq %rax, 0x98(%rsp)
cmpl $-0x1, 0xb8(%rax)
jne 0xe676
movl 0xb8(%rbp), %ecx
incl %ecx
movl %ecx, 0xb8(%rax)
movq %r14, %rdi
movq %r13, %rsi
callq 0xf85e
incq %r12
jmp 0xe641
xorl %eax, %eax
cmpq 0x18(%rsp), %r15
je 0xe6dc
movq %r15, %rsi
movl 0xb8(%r15), %ecx
decl %ecx
xorl %ebp, %ebp
movq %rax, %r15
cmpq $0x3, %rbp
je 0xe67d
movq 0x10(%rsi,%rbp,8), %r15
cmpl %ecx, 0xb8(%r15)
je 0xe6b1
incq %rbp
movq %r15, %rax
jmp 0xe695
movl $0x1, 0x94(%rsi,%rbp,4)
movq %r13, %rdi
movl %ebp, %edx
callq 0xf05e
movslq 0x98(%rsp,%rbp,4), %rax
orl $-0x1, 0x94(%r15,%rax,4)
movq %r15, %rax
jmp 0xe67d
movq 0x10(%rsp), %rax
movabsq $0x300000001, %r15      # imm = 0x300000001
testq %rax, %rax
je 0xe7b2
movl 0xb4(%rax), %ecx
cmpl 0xb4(%rbx), %ecx
jne 0xe70c
movl $0xfffffffe, 0xb8(%rax) # imm = 0xFFFFFFFE
movq (%rax), %rax
jmp 0xe6eb
leaq 0xc8(%rsp), %rbp
movq %rbp, %rdi
leaq 0x306e(%rip), %rsi      # 0x11791
movq %r13, %rdx
callq 0x3e82
movq %rbp, %rdi
pushq $0x3
popq %rsi
callq 0x3d1a
movq 0x10(%rsp), %r12
movq %rbp, %rdi
callq 0x3458
movq 0x18(%rsp), %rax
movl (%rsp), %ecx
movl %ecx, 0xb8(%rax)
movl 0xc(%rsp), %eax
movl %eax, 0xb8(%r15)
movq %r12, %rax
movabsq $0x300000001, %r15      # imm = 0x300000001
pushq $-0x10
popq %rdx
testq %rax, %rax
je 0xe7b2
movl 0xb4(%rax), %ecx
cmpl 0xb4(%rbx), %ecx
jne 0xe7ad
cmpl $-0x2, 0xb8(%rax)
je 0xe78f
orl $-0x1, 0xb8(%rax)
movq %rdx, %rcx
testq %rcx, %rcx
je 0xe7ad
andl $0x0, 0xa4(%rax,%rcx)
andl $0x0, 0xb4(%rax,%rcx)
addq $0x4, %rcx
jmp 0xe792
movq (%rax), %rax
jmp 0xe76c
movq %r14, %rdi
callq 0xf158
pushq $0x2
popq %rsi
jmp 0xe43f
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
jmp 0xe7ff
jmp 0xe827
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
jmp 0xe813
jmp 0xe81a
jmp 0xe827
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x3458
jmp 0xe82a
jmp 0xe827
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x3458
jmp 0xe834
movq %rax, %rbx
jmp 0xe834
jmp 0xe827
jmp 0xe827
jmp 0xe827
jmp 0xe827
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0xf158
movq %rbx, %rdi
callq 0x33d0