// File: /workspace/github_cpp_makefile_star2_O2/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, %rbx
leaq 0x498a(%rip), %rsi      # 0x115f0
leaq 0x38(%rsp), %rdi
movq %rsp, %rdx
callq 0x3e82
leaq 0x38(%rsp), %rdi
pushq $0x2
popq %rsi
callq 0x3d1a
leaq 0x38(%rsp), %rdi
callq 0x3458
movq 0x8(%rbx), %rcx
movq (%rcx), %rax
movq 0x38(%rax), %r14
movl (%rbx), %eax
movslq %eax, %rsi
xorl %r8d, %r8d
testl %esi, %esi
movl $0x0, %edx
cmovgl %esi, %edx
movq %r8, %rdi
cmpq %r8, %rdx
je 0xccbe
movq (%rcx,%rdi,8), %r9
leaq 0x1(%rdi), %r8
cmpb $0x0, 0x32(%r9)
jne 0xcca7
movslq 0x18(%rbx), %r9
movq 0x58(%r14), %r8
cmpl $0x2, (%r8,%r9,4)
jne 0xcce4
movq %r14, %rdi
callq 0xc7d2
movl (%rbx), %eax
movq 0x8(%rbx), %rcx
xorl %edx, %edx
testl %eax, %eax
cmovgl %eax, %edx
jmp 0xccf4
cmpq %rsi, %rdi
jl 0xcccd
movslq 0x1c(%rbx), %rsi
cmpl $0x2, (%r8,%rsi,4)
je 0xcccd
xorl %esi, %esi
cmpq %rsi, %rdx
je 0xcd08
movq (%rcx,%rsi,8), %rdi
movb $0x0, 0x32(%rdi)
incq %rsi
jmp 0xccf6
movslq 0x18(%rbx), %rcx
movq 0x58(%r14), %rdx
pushq $0x1
popq %rsi
movl %esi, (%rdx,%rcx,4)
movslq 0x1c(%rbx), %rcx
movl %esi, (%rdx,%rcx,4)
movq %rsp, %r14
andq $0x0, 0x10(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
xorl %r12d, %r12d
leaq 0x28(%rsp), %r15
cltq
cmpq %rax, %r12
jge 0xcd68
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
movq (%rax,%r12,8), %rdi
movzbl (%rcx,%r12), %esi
callq 0xacdc
movq %rax, 0x28(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x6a7c
incq %r12
movl (%rbx), %eax
jmp 0xcd34
xorl %r14d, %r14d
leaq 0x28(%rsp), %r15
movq %rbx, 0x20(%rsp)
movslq (%rbx), %rax
leaq -0x1(%rax), %rcx
cmpq %rcx, %r14
jge 0xce33
movq (%rsp), %rax
movq (%rax,%r14,8), %rcx
movq 0x8(%rax,%r14,8), %rax
movq 0x10(%rcx), %rdx
movq 0x28(%rcx), %rcx
movq 0x88(%rdx), %rbx
movq (%rax), %rdx
movq 0x18(%rax), %rax
movq 0x88(%rdx), %r12
movq 0x88(%rcx), %r13
movq 0x88(%rax), %rbp
movq %r15, %rdi
xorl %esi, %esi
pushq $0x1
popq %rdx
pushq $0x3
popq %rcx
pushq $0x2
popq %r8
callq 0x6790
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %r15, %rcx
callq 0xa5d2
movq %r15, %rdi
xorl %esi, %esi
pushq $0x1
popq %rdx
pushq $0x3
popq %rcx
pushq $0x2
popq %r8
callq 0x6790
movq %r13, %rdi
movq %rbp, %rsi
xorl %edx, %edx
movq %r15, %rcx
callq 0xa5d2
movq (%rsp), %rax
movq (%rax,%r14,8), %rdi
movq 0x8(%rax,%r14,8), %rsi
movq 0x20(%rsp), %rbx
movq 0x10(%rbx), %rax
movzbl (%r14,%rax), %edx
movzbl 0x1(%r14,%rax), %ecx
incq %r14
callq 0xac47
jmp 0xcd75
xorl %r15d, %r15d
pushq $0x40
popq %r14
cltq
cmpq %rax, %r15
jge 0xce58
movq (%rsp), %rax
movq (%rax,%r15,8), %rdi
movq %r14, %rsi
callq 0x3250
incq %r15
movl (%rbx), %eax
jmp 0xce3a
movq %rsp, %rdi
callq 0x6f9c
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x3458
jmp 0xce94
movq %rax, %rbx
jmp 0xce94
jmp 0xce89
jmp 0xce89
jmp 0xce89
movq %rax, %rbx
movq %rsp, %rdi
callq 0x6f9c
movq %rbx, %rdi
callq 0x33d0