// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r14
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x28(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x92e7(%rip), %rsi      # 0x175b6
leaq 0x92e4(%rip), %rdx      # 0x175ba
leaq 0x18(%rsp), %r12
movq %r12, %rdi
callq 0x86fe
movq %r12, %rdi
movl $0x3, %esi
callq 0x4209
movq 0x18(%rsp), %rdi
cmpq %r13, %rdi
je 0xe307
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x3220
movq %r15, 0x38(%rbx)
movb $0x1, 0x32(%rbx)
movw $0x0, 0x30(%rbx)
movl $0xc0, %edi
callq 0x3210
movq %rax, %r12
testq %r14, %r14
je 0xe32c
movq (%r14), %rax
jmp 0xe32e
xorl %eax, %eax
movq %rax, (%rsp)
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movl %ebp, %r9d
callq 0xdc7c
movq %r12, (%rbx)
movl $0xc0, %edi
callq 0x3210
movq %rax, %r15
movq 0x38(%rbx), %rsi
testq %r14, %r14
je 0xe366
movq 0x8(%r14), %rax
jmp 0xe368
xorl %eax, %eax
movq %rax, (%rsp)
movq %r15, %rdi
xorl %edx, %edx
movl $0x1, %ecx
xorl %r8d, %r8d
movl %ebp, %r9d
callq 0xdc7c
movq %r15, 0x8(%rbx)
movl $0xc0, %edi
callq 0x3210
movq %rax, %r15
movq 0x38(%rbx), %rsi
testq %r14, %r14
je 0xe3a1
movq 0x10(%r14), %rax
jmp 0xe3a3
xorl %eax, %eax
movq %rax, (%rsp)
movq %r15, %rdi
xorl %edx, %edx
movl $0x2, %ecx
xorl %r8d, %r8d
movl %ebp, %r9d
callq 0xdc7c
movq %r15, 0x10(%rbx)
movl $0xc0, %edi
callq 0x3210
movq %rax, %r15
movq 0x38(%rbx), %rsi
testq %r14, %r14
je 0xe3dc
movq 0x18(%r14), %rax
jmp 0xe3de
xorl %eax, %eax
movq %rax, (%rsp)
movq %r15, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
movl %ebp, %r9d
callq 0xdc7c
movq %r15, 0x18(%rbx)
movl $0xc0, %edi
callq 0x3210
movq %rax, %r15
movq 0x38(%rbx), %rsi
testq %r14, %r14
je 0xe417
movq 0x20(%r14), %rax
jmp 0xe419
xorl %eax, %eax
movq %rax, (%rsp)
movq %r15, %rdi
xorl %edx, %edx
movl $0x1, %ecx
movl $0x1, %r8d
movl %ebp, %r9d
callq 0xdc7c
movq %r15, 0x20(%rbx)
movl $0xc0, %edi
callq 0x3210
movq %rax, %r15
movq 0x38(%rbx), %rsi
testq %r14, %r14
je 0xe455
movq 0x28(%r14), %rax
jmp 0xe457
xorl %eax, %eax
movq %rax, (%rsp)
movq %r15, %rdi
xorl %edx, %edx
movl $0x2, %ecx
movl $0x1, %r8d
movl %ebp, %r9d
callq 0xdc7c
movq %r15, 0x28(%rbx)
movq (%rbx), %r14
movq 0x8(%rbx), %r15
leaq 0x8(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
movl $0x1, %edx
movl $0x3, %ecx
movl $0x2, %r8d
callq 0x8630
movq %r14, %rdi
movq %r15, %rsi
movl $0x3, %edx
movq %r12, %rcx
callq 0xde78
movq 0x8(%rbx), %r14
movq 0x10(%rbx), %r15
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movl $0x3, %esi
movl $0x1, %edx
movl $0x2, %ecx
xorl %r8d, %r8d
callq 0x8630
movq %r14, %rdi
movq %r15, %rsi
movl $0x3, %edx
movq %r12, %rcx
callq 0xde78
movq 0x18(%rbx), %r14
movq 0x20(%rbx), %r15
leaq 0x8(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
movl $0x3, %edx
movl $0x2, %ecx
movl $0x1, %r8d
callq 0x8630
movq %r14, %rdi
movq %r15, %rsi
movl $0x3, %edx
movq %r12, %rcx
callq 0xde78
movq 0x20(%rbx), %r14
movq 0x28(%rbx), %r15
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movl $0x3, %esi
movl $0x1, %edx
movl $0x2, %ecx
xorl %r8d, %r8d
callq 0x8630
movq %r14, %rdi
movq %r15, %rsi
movl $0x3, %edx
movq %r12, %rcx
callq 0xde78
movq 0x8(%rbx), %r14
movq 0x18(%rbx), %r15
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movl $0x1, %esi
xorl %edx, %edx
movl $0x2, %ecx
movl $0x3, %r8d
callq 0x8630
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
movq %r12, %rcx
callq 0xde78
movq 0x10(%rbx), %r14
movq 0x20(%rbx), %rbx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movl $0x1, %esi
xorl %edx, %edx
movl $0x2, %ecx
movl $0x3, %r8d
callq 0x8630
movq %r14, %rdi
movq %rbx, %rsi
movl $0x1, %edx
movq %r15, %rcx
callq 0xde78
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xe5e9
jmp 0xe5e9
jmp 0xe5e9
jmp 0xe5e9
movq %rax, %rbx
movl $0xc0, %esi
movq %r15, %rdi
callq 0x3220
movq %rbx, %rdi
callq 0x33e0
movq %rax, %rbx
movl $0xc0, %esi
movq %r12, %rdi
jmp 0xe5f4
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r13, %rdi
je 0xe5f9
movq 0x28(%rsp), %rsi
incq %rsi
jmp 0xe5f4