// File: /workspace/github_cpp_makefile_star2_O3/MarkCBell[P]twister/./twister/kernel/twister.cpp
// Function: annulus::drill()
void annulus::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 (need_new_layer) M->insert_layer();
	
	for (int i = 0; i < length; i++)
		sq[i]->set_status(false);
	
	// For each cube in the thickened annulus replace its child (in the new layer) by 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; i++)
	{
		int j = (i + 1) % length;
		// 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), %r14
movq %r14, -0x10(%r14)
leaq 0x7211(%rip), %rsi      # 0x17698
leaq 0x720f(%rip), %rdx      # 0x1769d
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0x892e
movq %rbx, %rdi
movl $0x2, %esi
callq 0x4229
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0x104bf
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3220
movslq (%r12), %rax
testq %rax, %rax
jle 0x10567
movq 0x8(%r12), %rcx
movq (%rcx), %rdx
movq 0x38(%rdx), %rdi
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
cmpb $0x0, 0x32(%rsi)
je 0x104ee
incq %rdx
cmpq %rdx, %rax
jne 0x104da
jmp 0x104f7
callq 0x106e2
movl (%r12), %eax
testl %eax, %eax
jle 0x10567
movq 0x8(%r12), %rcx
movl %eax, %edx
xorl %esi, %esi
movq (%rcx,%rsi,8), %rdi
movb $0x0, 0x32(%rdi)
incq %rsi
cmpq %rsi, %rdx
jne 0x10504
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
testl %eax, %eax
jle 0x10577
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 0xe872
movq %rax, 0x28(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x8ca4
incq %rbx
movslq (%r12), %rax
cmpq %rax, %rbx
jl 0x10532
jmp 0x10577
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
xorl %r14d, %r14d
leaq 0x28(%rsp), %rbx
movq %r12, 0x18(%rsp)
movslq (%r12), %rcx
cmpq %rcx, %r14
jge 0x1065a
movq (%rsp), %rsi
movq (%rsi,%r14,8), %rdi
leal 0x1(%r14), %eax
cltd
idivl %ecx
movl %edx, %r15d
movq 0x10(%rdi), %rax
movq 0x28(%rdi), %rcx
movq 0x88(%rax), %rbp
movq (%rsi,%r15,8), %rax
movq (%rax), %rdx
movq 0x18(%rax), %rax
movq 0x88(%rdx), %r12
movq 0x88(%rcx), %rcx
movq %rcx, 0x20(%rsp)
movq 0x88(%rax), %r13
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
movl $0x3, %ecx
movl $0x2, %r8d
callq 0x8860
movq %rbp, %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0xe04e
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
movl $0x3, %ecx
movl $0x2, %r8d
callq 0x8860
movq 0x20(%rsp), %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0xe04e
movq (%rsp), %rax
movq (%rax,%r14,8), %rdi
movq (%rax,%r15,8), %rsi
movq 0x18(%rsp), %r12
movq 0x10(%r12), %rax
movzbl (%rax,%r14), %edx
movzbl (%rax,%r15), %ecx
incq %r14
callq 0xe7d1
jmp 0x10584
testl %ecx, %ecx
jle 0x1067e
xorl %ebx, %ebx
movq (%rsp), %rax
movq (%rax,%rbx,8), %rdi
movl $0x40, %esi
callq 0x3220
incq %rbx
movslq (%r12), %rax
cmpq %rax, %rbx
jl 0x10660
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x10694
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 %r14, %rdi
je 0x106d9
movq 0x48(%rsp), %rsi
incq %rsi
jmp 0x106d4
jmp 0x106c0
jmp 0x106c0
jmp 0x106c0
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x106d9
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x3220
movq %rbx, %rdi
callq 0x33e0
nop