// File: MarkCBell[P]twister/./twister/kernel/twister.cpp
// Function: cube::cube(manifold&, int, cube*)
cube::cube(manifold &home_in, int layer_number, cube *parent_cube)
{
	output_debugging("cube", 3);
	
	home = &home_in;
	status = true;
	
	is_glued[0] = is_glued[1] = false;
	
	topleft = new tetra(home, cubie, top, left, layer_number, (parent_cube != NULL) ? parent_cube->get_tetra(top, left) : NULL);
	midleft = new tetra(home, cubie, mid, left, layer_number, (parent_cube != NULL) ? parent_cube->get_tetra(mid, left) : NULL);
	lowleft = new tetra(home, cubie, low, left, layer_number, (parent_cube != NULL) ? parent_cube->get_tetra(low, left) : NULL);
	
	topright = new tetra(home, cubie, top, right, layer_number, (parent_cube != NULL) ? parent_cube->get_tetra(top, right) : NULL);
	midright = new tetra(home, cubie, mid, right, layer_number, (parent_cube != NULL) ? parent_cube->get_tetra(mid, right) : NULL);
	lowright = new tetra(home, cubie, low, right, layer_number, (parent_cube != NULL) ? parent_cube->get_tetra(low, right) : NULL);
	
	// Assemble these tetrahedra into a cube.
	// We'll glue these into two triangular prisms, and then a cube.
	// See the diagram of the cube.
	
	// Gluings inside left prism.
	topleft->gluesym(midleft, 3, perm(0,1,3,2));
	midleft->gluesym(lowleft, 3, perm(3,1,2,0));
	
	// Gluings inside right prism.
	topright->gluesym(midright, 3, perm(0,3,2,1));
	midright->gluesym(lowright, 3, perm(3,1,2,0));
	
	// Gluings between the two prisms.
	midleft->gluesym(topright, 1, perm(1,0,2,3));
	lowleft->gluesym(midright, 1, perm(1,0,2,3));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x3560
movq -0xc0(%rbp), %rdx
leaq 0xfb4f(%rip), %rsi      # 0x27532
leaq -0x40(%rbp), %rdi
callq 0x4e10
jmp 0x179ee
leaq -0x40(%rbp), %rdi
movl $0x3, %esi
callq 0x4c10
jmp 0x179fe
leaq -0x40(%rbp), %rdi
callq 0x35f8
leaq -0x41(%rbp), %rdi
callq 0x3360
movq -0xc8(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, 0x38(%rax)
movb $0x1, 0x32(%rax)
movb $0x0, 0x31(%rax)
movb $0x0, 0x30(%rax)
movl $0xc0, %edi
callq 0x3300
movq %rax, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, -0xe0(%rbp)
movq 0x38(%rax), %rax
movq %rax, -0xd8(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0xcc(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x17a87
movq -0x20(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x20bc0
movq %rax, -0xe8(%rbp)
jmp 0x17a77
movq -0xe8(%rbp), %rax
movq %rax, -0xf0(%rbp)
jmp 0x17a92
xorl %eax, %eax
movq %rax, -0xf0(%rbp)
jmp 0x17a92
movl -0xcc(%rbp), %r9d
movq -0xd8(%rbp), %rsi
movq -0xe0(%rbp), %rdi
movq -0xf0(%rbp), %rcx
movq %rsp, %rax
movq %rcx, (%rax)
xorl %r8d, %r8d
movl %r8d, %edx
movl %r8d, %ecx
callq 0x17070
jmp 0x17ac4
movq -0xc8(%rbp), %rax
movq -0xe0(%rbp), %rcx
movq %rcx, (%rax)
movl $0xc0, %edi
callq 0x3300
movq %rax, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, -0x108(%rbp)
movq 0x38(%rax), %rax
movq %rax, -0x100(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0xf4(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x17b34
movq -0x20(%rbp), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x20bc0
movq %rax, -0x110(%rbp)
jmp 0x17b24
movq -0x110(%rbp), %rax
movq %rax, -0x118(%rbp)
jmp 0x17b3f
xorl %eax, %eax
movq %rax, -0x118(%rbp)
jmp 0x17b3f
movl -0xf4(%rbp), %r9d
movq -0x100(%rbp), %rsi
movq -0x108(%rbp), %rdi
movq -0x118(%rbp), %rcx
movq %rsp, %rax
movq %rcx, (%rax)
movl $0x1, %ecx
xorl %r8d, %r8d
movl %r8d, %edx
callq 0x17070
jmp 0x17b73
movq -0xc8(%rbp), %rax
movq -0x108(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0xc0, %edi
callq 0x3300
movq %rax, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, -0x130(%rbp)
movq 0x38(%rax), %rax
movq %rax, -0x128(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x11c(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x17be4
movq -0x20(%rbp), %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x20bc0
movq %rax, -0x138(%rbp)
jmp 0x17bd4
movq -0x138(%rbp), %rax
movq %rax, -0x140(%rbp)
jmp 0x17bef
xorl %eax, %eax
movq %rax, -0x140(%rbp)
jmp 0x17bef
movl -0x11c(%rbp), %r9d
movq -0x128(%rbp), %rsi
movq -0x130(%rbp), %rdi
movq -0x140(%rbp), %rcx
movq %rsp, %rax
movq %rcx, (%rax)
movl $0x2, %ecx
xorl %r8d, %r8d
movl %r8d, %edx
callq 0x17070
jmp 0x17c23
movq -0xc8(%rbp), %rax
movq -0x130(%rbp), %rcx
movq %rcx, 0x10(%rax)
movl $0xc0, %edi
callq 0x3300
movq %rax, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, -0x158(%rbp)
movq 0x38(%rax), %rax
movq %rax, -0x150(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x144(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x17c94
movq -0x20(%rbp), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x20bc0
movq %rax, -0x160(%rbp)
jmp 0x17c84
movq -0x160(%rbp), %rax
movq %rax, -0x168(%rbp)
jmp 0x17c9f
xorl %eax, %eax
movq %rax, -0x168(%rbp)
jmp 0x17c9f
movl -0x144(%rbp), %r9d
movq -0x150(%rbp), %rsi
movq -0x158(%rbp), %rdi
movq -0x168(%rbp), %rcx
movq %rsp, %rax
movq %rcx, (%rax)
xorl %ecx, %ecx
movl $0x1, %r8d
movl %ecx, %edx
callq 0x17070
jmp 0x17cd2
movq -0xc8(%rbp), %rax
movq -0x158(%rbp), %rcx
movq %rcx, 0x18(%rax)
movl $0xc0, %edi
callq 0x3300
movq %rax, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, -0x180(%rbp)
movq 0x38(%rax), %rax
movq %rax, -0x178(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x16c(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x17d43
movq -0x20(%rbp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0x20bc0
movq %rax, -0x188(%rbp)
jmp 0x17d33
movq -0x188(%rbp), %rax
movq %rax, -0x190(%rbp)
jmp 0x17d4e
xorl %eax, %eax
movq %rax, -0x190(%rbp)
jmp 0x17d4e
movl -0x16c(%rbp), %r9d
movq -0x178(%rbp), %rsi
movq -0x180(%rbp), %rdi
movq -0x190(%rbp), %rcx
movq %rsp, %rax
movq %rcx, (%rax)
xorl %edx, %edx
movl $0x1, %r8d
movl %r8d, %ecx
callq 0x17070
jmp 0x17d82
movq -0xc8(%rbp), %rax
movq -0x180(%rbp), %rcx
movq %rcx, 0x20(%rax)
movl $0xc0, %edi
callq 0x3300
movq %rax, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, -0x1a8(%rbp)
movq 0x38(%rax), %rax
movq %rax, -0x1a0(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x194(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x17df6
movq -0x20(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x20bc0
movq %rax, -0x1b0(%rbp)
jmp 0x17de6
movq -0x1b0(%rbp), %rax
movq %rax, -0x1b8(%rbp)
jmp 0x17e01
xorl %eax, %eax
movq %rax, -0x1b8(%rbp)
jmp 0x17e01
movl -0x194(%rbp), %r9d
movq -0x1a0(%rbp), %rsi
movq -0x1a8(%rbp), %rdi
movq -0x1b8(%rbp), %rcx
movq %rsp, %rax
movq %rcx, (%rax)
xorl %edx, %edx
movl $0x2, %ecx
movl $0x1, %r8d
callq 0x17070
jmp 0x17e37
movq -0xc8(%rbp), %rax
movq -0x1a8(%rbp), %rcx
movq %rcx, 0x28(%rax)
movq (%rax), %rcx
movq %rcx, -0x218(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x210(%rbp)
leaq -0x64(%rbp), %rdi
xorl %esi, %esi
movl $0x1, %edx
movl $0x3, %ecx
movl $0x2, %r8d
callq 0x9cc0
movq -0x218(%rbp), %rdi
movq -0x210(%rbp), %rsi
movl $0x3, %edx
leaq -0x64(%rbp), %rcx
callq 0x17390
movq -0xc8(%rbp), %rax
movq 0x8(%rax), %rcx
movq %rcx, -0x208(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0x200(%rbp)
leaq -0x74(%rbp), %rdi
movl $0x3, %esi
movl $0x1, %edx
movl $0x2, %ecx
xorl %r8d, %r8d
callq 0x9cc0
movq -0x208(%rbp), %rdi
movq -0x200(%rbp), %rsi
movl $0x3, %edx
leaq -0x74(%rbp), %rcx
callq 0x17390
movq -0xc8(%rbp), %rax
movq 0x18(%rax), %rcx
movq %rcx, -0x1f8(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x1f0(%rbp)
leaq -0x84(%rbp), %rdi
xorl %esi, %esi
movl $0x3, %edx
movl $0x2, %ecx
movl $0x1, %r8d
callq 0x9cc0
movq -0x1f8(%rbp), %rdi
movq -0x1f0(%rbp), %rsi
movl $0x3, %edx
leaq -0x84(%rbp), %rcx
callq 0x17390
movq -0xc8(%rbp), %rax
movq 0x20(%rax), %rcx
movq %rcx, -0x1e8(%rbp)
movq 0x28(%rax), %rax
movq %rax, -0x1e0(%rbp)
leaq -0x94(%rbp), %rdi
movl $0x3, %esi
movl $0x1, %edx
movl $0x2, %ecx
xorl %r8d, %r8d
callq 0x9cc0
movq -0x1e8(%rbp), %rdi
movq -0x1e0(%rbp), %rsi
movl $0x3, %edx
leaq -0x94(%rbp), %rcx
callq 0x17390
movq -0xc8(%rbp), %rax
movq 0x8(%rax), %rcx
movq %rcx, -0x1d8(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x1d0(%rbp)
leaq -0xa4(%rbp), %rdi
movl $0x1, %esi
xorl %edx, %edx
movl $0x2, %ecx
movl $0x3, %r8d
callq 0x9cc0
movq -0x1d8(%rbp), %rdi
movq -0x1d0(%rbp), %rsi
movl $0x1, %edx
leaq -0xa4(%rbp), %rcx
callq 0x17390
movq -0xc8(%rbp), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0x1c8(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x1c0(%rbp)
leaq -0xb4(%rbp), %rdi
movl $0x1, %esi
xorl %edx, %edx
movl $0x2, %ecx
movl $0x3, %r8d
callq 0x9cc0
movq -0x1c8(%rbp), %rdi
movq -0x1c0(%rbp), %rsi
movl $0x1, %edx
leaq -0xb4(%rbp), %rcx
callq 0x17390
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1807d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x35f8
leaq -0x41(%rbp), %rdi
callq 0x3360
jmp 0x18146
movq -0xe0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0xc0, %esi
callq 0x3310
jmp 0x18146
movq -0x108(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0xc0, %esi
callq 0x3310
jmp 0x18146
movq -0x130(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0xc0, %esi
callq 0x3310
jmp 0x18146
movq -0x158(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0xc0, %esi
callq 0x3310
jmp 0x18146
movq -0x180(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0xc0, %esi
callq 0x3310
jmp 0x18146
movq -0x1a8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0xc0, %esi
callq 0x3310
movq -0x50(%rbp), %rdi
callq 0x3550
nop