// File: /workspace/github_cpp_makefile_star2_O1/MarkCBell[P]twister/./twister/kernel/twister.cpp
// Function: rectangle::drill()
void rectangle::drill()
{
	output_debugging("drill", 2);
	
	manifold *M = sq[0]->home;
	
	// First find out if we need a new layer.
	bool need_new_layer = false;
	for (int i = 0; i < length; i++)
		if (! sq[i]->get_status())
		{
			need_new_layer = true;
			break;
		}
	
	if ((M->marked_points[front] == half_twisted) || (M->marked_points[back] == half_twisted))
		need_new_layer = true;
	
	if (need_new_layer) M->insert_layer();
	
	for (int i = 0; i < length; i++)
		sq[i]->set_status(false);
	
	M->marked_points[front] = drilled;
	M->marked_points[back] = drilled;
	
	// Convert each child cube to a gadget.
	std::vector<cube*> new_cubes;
	for (int i = 0; i < length; i++)
		new_cubes.push_back(convert_cube_to_gadget(sq[i], upright[i]));
	
	// Gadget pups can't get horizontal gluing information from their parents.
	// So we must provide it now.
	for (int i = 0; i < length - 1; i++)
	{
		int j = i + 1;
		// Glue pup_gadgets together.
		tetra *current_top_back = new_cubes[i]->get_tetra(low, left)->get_child();
		tetra *next_top_front = new_cubes[j]->get_tetra(top, left)->get_child();
		tetra *current_bottom_back = new_cubes[i]->get_tetra(low, right)->get_child();
		tetra *next_bottom_front = new_cubes[j]->get_tetra(top, right)->get_child();
		
		// (*1*) Gadgets were designed so this was true. :)
		current_top_back->gluesym(next_top_front, 0, perm(0,1,3,2));
		current_bottom_back->gluesym(next_bottom_front, 0, perm(0,1,3,2));
		
		glue_cubes(new_cubes[i], new_cubes[j], upright[i], upright[j]);
	}
	
	for (int i = 0; i < length; i++)
		delete new_cubes[i];
	
	return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r12
leaq 0x48(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x6b67(%rip), %rsi      # 0x17658
leaq 0x6b65(%rip), %rdx      # 0x1765d
leaq 0x38(%rsp), %r14
movq %r14, %rdi
callq 0x86fe
movq %r14, %rdi
movl $0x2, %esi
callq 0x4209
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x10b29
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3220
movq 0x8(%r12), %rax
movq (%rax), %rcx
movq 0x38(%rcx), %r14
movslq (%r12), %rcx
testq %rcx, %rcx
setg %dl
jle 0x10b6b
movq (%rax), %rsi
cmpb $0x1, 0x32(%rsi)
jne 0x10b6b
movl $0x1, %esi
movq %rsi, %rdx
cmpq %rsi, %rcx
je 0x10b65
movq (%rax,%rdx,8), %rdi
leaq 0x1(%rdx), %rsi
cmpb $0x0, 0x32(%rdi)
jne 0x10b4f
cmpq %rcx, %rdx
setb %dl
movslq 0x18(%r12), %rcx
movq 0x58(%r14), %rax
cmpl $0x2, (%rax,%rcx,4)
je 0x10b8c
movslq 0x1c(%r12), %rcx
cmpl $0x2, (%rax,%rcx,4)
setne %al
notb %dl
testb %al, %dl
jne 0x10b94
movq %r14, %rdi
callq 0x105e6
movslq (%r12), %rax
testq %rax, %rax
jle 0x10bb4
movq 0x8(%r12), %rcx
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
movb $0x0, 0x32(%rsi)
incq %rdx
cmpq %rdx, %rax
jne 0x10ba4
movslq 0x18(%r12), %rax
movq 0x58(%r14), %rcx
movl $0x1, %edx
movl %edx, (%rcx,%rax,4)
movslq 0x1c(%r12), %rax
movl %edx, (%rcx,%rax,4)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
cmpl $0x0, (%r12)
jle 0x10c21
xorl %ebx, %ebx
movq %rsp, %r14
leaq 0x28(%rsp), %r15
movq 0x8(%r12), %rax
movq 0x10(%r12), %rcx
movq (%rax,%rbx,8), %rdi
movzbl (%rcx,%rbx), %esi
callq 0xe703
movq %rax, 0x28(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x8aa2
incq %rbx
movslq (%r12), %rax
cmpq %rax, %rbx
jl 0x10bee
xorl %ebx, %ebx
leaq 0x28(%rsp), %r13
movq %r12, 0x20(%rsp)
movslq (%r12), %rax
decq %rax
cmpq %rax, %rbx
jge 0x10cf6
movq (%rsp), %rax
movq (%rax,%rbx,8), %rcx
movq 0x8(%rax,%rbx,8), %rax
movq 0x10(%rcx), %rdx
movq 0x28(%rcx), %rcx
movq 0x88(%rdx), %r14
movq (%rax), %rdx
movq 0x18(%rax), %rax
movq 0x88(%rdx), %rbp
movq 0x88(%rcx), %r15
movq 0x88(%rax), %r12
movq %r13, %rdi
xorl %esi, %esi
movl $0x1, %edx
movl $0x3, %ecx
movl $0x2, %r8d
callq 0x8630
movq %r14, %rdi
movq %rbp, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0xde78
movq %r13, %rdi
xorl %esi, %esi
movl $0x1, %edx
movl $0x3, %ecx
movl $0x2, %r8d
callq 0x8630
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0xde78
movq (%rsp), %rax
movq (%rax,%rbx,8), %rdi
movq 0x8(%rax,%rbx,8), %rsi
movq 0x20(%rsp), %r12
movq 0x10(%r12), %rax
movzbl (%rbx,%rax), %edx
movzbl 0x1(%rbx,%rax), %ecx
incq %rbx
callq 0xe625
jmp 0x10c2d
cmpl $0x0, (%r12)
jle 0x10d22
xorl %ebx, %ebx
movq (%rsp), %rax
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x10d16
movl $0x40, %esi
callq 0x3220
incq %rbx
movslq (%r12), %rax
cmpq %rax, %rbx
jl 0x10cff
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x10d38
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x3220
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x10d7d
movq 0x48(%rsp), %rsi
incq %rsi
jmp 0x10d78
jmp 0x10d64
jmp 0x10d64
jmp 0x10d64
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x10d7d
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x3220
movq %rbx, %rdi
callq 0x33e0