// File: 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
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
leaq -0x29(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x3560
movq -0xd8(%rbp), %rdx
leaq 0xc30c(%rip), %rsi      # 0x275d4
leaq -0x28(%rbp), %rdi
callq 0x4e10
jmp 0x1b2d3
leaq -0x28(%rbp), %rdi
movl $0x2, %esi
callq 0x4c10
jmp 0x1b2e3
leaq -0x28(%rbp), %rdi
callq 0x35f8
leaq -0x29(%rbp), %rdi
callq 0x3360
movq -0xe0(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq 0x38(%rax), %rax
movq %rax, -0x48(%rbp)
movb $0x0, -0x49(%rbp)
movl $0x0, -0x50(%rbp)
movq -0xe0(%rbp), %rcx
movl -0x50(%rbp), %eax
cmpl (%rcx), %eax
jge 0x1b384
movq -0xe0(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x211c0
testb $0x1, %al
jne 0x1b377
movb $0x1, -0x49(%rbp)
jmp 0x1b384
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1b369
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x35f8
leaq -0x29(%rbp), %rdi
callq 0x3360
jmp 0x1b767
jmp 0x1b379
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1b316
testb $0x1, -0x49(%rbp)
je 0x1b393
movq -0x48(%rbp), %rdi
callq 0x1b770
movl $0x0, -0x54(%rbp)
movq -0xe0(%rbp), %rcx
movl -0x54(%rbp), %eax
cmpl (%rcx), %eax
jge 0x1b3cd
movq -0xe0(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x54(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
xorl %esi, %esi
callq 0x9b30
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x1b39a
leaq -0x70(%rbp), %rdi
callq 0x9080
movl $0x0, -0x74(%rbp)
movq -0xe0(%rbp), %rcx
movl -0x74(%rbp), %eax
cmpl (%rcx), %eax
jge 0x1b458
movq -0xe0(%rbp), %rax
movslq -0x74(%rbp), %rcx
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rax
movq (%rdx,%rcx,8), %rdi
movzbl (%rax,%rcx), %esi
andl $0x1, %esi
callq 0x183c0
movq %rax, -0xe8(%rbp)
jmp 0x1b417
movq -0xe8(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x8cd0
jmp 0x1b431
jmp 0x1b433
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x1b3dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x9540
jmp 0x1b767
movl $0x0, -0x84(%rbp)
movq -0xe0(%rbp), %rcx
movl -0x84(%rbp), %eax
cmpl (%rcx), %eax
jge 0x1b6f6
movq -0xe0(%rbp), %rcx
movl -0x84(%rbp), %eax
incl %eax
movl (%rcx), %ecx
cltd
idivl %ecx
movl %edx, -0x88(%rbp)
movslq -0x84(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x8d20
movq (%rax), %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x20bc0
movq %rax, -0xf0(%rbp)
jmp 0x1b4b9
movq -0xf0(%rbp), %rdi
callq 0x20e60
movq %rax, -0xf8(%rbp)
jmp 0x1b4ce
movq -0xf8(%rbp), %rax
movq %rax, -0x90(%rbp)
movslq -0x88(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x8d20
movq (%rax), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x20bc0
movq %rax, -0x100(%rbp)
jmp 0x1b501
movq -0x100(%rbp), %rdi
callq 0x20e60
movq %rax, -0x108(%rbp)
jmp 0x1b516
movq -0x108(%rbp), %rax
movq %rax, -0x98(%rbp)
movslq -0x84(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x8d20
movq (%rax), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x20bc0
movq %rax, -0x110(%rbp)
jmp 0x1b54f
movq -0x110(%rbp), %rdi
callq 0x20e60
movq %rax, -0x118(%rbp)
jmp 0x1b564
movq -0x118(%rbp), %rax
movq %rax, -0xa0(%rbp)
movslq -0x88(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x8d20
movq (%rax), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x20bc0
movq %rax, -0x120(%rbp)
jmp 0x1b59a
movq -0x120(%rbp), %rdi
callq 0x20e60
movq %rax, -0x128(%rbp)
jmp 0x1b5af
movq -0x128(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x130(%rbp)
leaq -0xb8(%rbp), %rdi
xorl %esi, %esi
movl $0x1, %edx
movl $0x3, %ecx
movl $0x2, %r8d
callq 0x9cc0
jmp 0x1b5f9
movq -0x130(%rbp), %rsi
movq -0x138(%rbp), %rdi
xorl %edx, %edx
leaq -0xb8(%rbp), %rcx
callq 0x17390
jmp 0x1b617
movq -0xa0(%rbp), %rax
movq %rax, -0x148(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x140(%rbp)
leaq -0xc8(%rbp), %rdi
xorl %esi, %esi
movl $0x1, %edx
movl $0x3, %ecx
movl $0x2, %r8d
callq 0x9cc0
jmp 0x1b653
movq -0x140(%rbp), %rsi
movq -0x148(%rbp), %rdi
xorl %edx, %edx
leaq -0xc8(%rbp), %rcx
callq 0x17390
jmp 0x1b671
movslq -0x84(%rbp), %rsi
leaq -0x70(%rbp), %rdi
movq %rdi, -0x158(%rbp)
callq 0x8d20
movq -0x158(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x150(%rbp)
movslq -0x88(%rbp), %rsi
callq 0x8d20
movq -0x150(%rbp), %rdi
movq %rax, %rcx
movq -0xe0(%rbp), %rax
movq (%rcx), %rsi
movq 0x10(%rax), %rax
movslq -0x84(%rbp), %rdx
movslq -0x88(%rbp), %rcx
movzbl (%rax,%rdx), %edx
andl $0x1, %edx
movzbl (%rax,%rcx), %ecx
andl $0x1, %ecx
callq 0x18150
jmp 0x1b6e0
jmp 0x1b6e2
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x1b462
movl $0x0, -0xcc(%rbp)
movq -0xe0(%rbp), %rcx
movl -0xcc(%rbp), %eax
cmpl (%rcx), %eax
jge 0x1b755
movslq -0xcc(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x8d20
movq (%rax), %rax
movq %rax, -0x160(%rbp)
cmpq $0x0, %rax
je 0x1b742
movq -0x160(%rbp), %rdi
movl $0x40, %esi
callq 0x3310
jmp 0x1b744
movl -0xcc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xcc(%rbp)
jmp 0x1b700
leaq -0x70(%rbp), %rdi
callq 0x9540
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x3550