// File: /workspace/github_cpp_makefile_star2_O2/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 0x6c08(%rip), %rsi      # 0x1154e
leaq 0x18(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x3e82
leaq 0x18(%rsp), %rdi
pushq $0x3
popq %rsi
callq 0x3d1a
leaq 0x18(%rsp), %rdi
callq 0x3458
movq %r15, 0x38(%rbx)
movb $0x1, 0x32(%rbx)
andw $0x0, 0x30(%rbx)
movl $0xc0, %edi
callq 0x3240
movq %rax, %r12
testq %r14, %r14
je 0xa990
movq (%r14), %rax
jmp 0xa992
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 0xa3fa
movq %r12, (%rbx)
movl $0xc0, %edi
callq 0x3240
movq %rax, %r15
movq 0x38(%rbx), %rsi
testq %r14, %r14
je 0xa9ca
movq 0x8(%r14), %rax
jmp 0xa9cc
xorl %eax, %eax
movq %rax, (%rsp)
pushq $0x1
popq %rcx
movq %r15, %rdi
xorl %edx, %edx
xorl %r8d, %r8d
movl %ebp, %r9d
callq 0xa3fa
movq %r15, 0x8(%rbx)
movl $0xc0, %edi
callq 0x3240
movq %rax, %r15
movq 0x38(%rbx), %rsi
testq %r14, %r14
je 0xaa03
movq 0x10(%r14), %rax
jmp 0xaa05
xorl %eax, %eax
movq %rax, (%rsp)
pushq $0x2
popq %rcx
movq %r15, %rdi
xorl %edx, %edx
xorl %r8d, %r8d
movl %ebp, %r9d
callq 0xa3fa
movq %r15, 0x10(%rbx)
movl $0xc0, %edi
callq 0x3240
movq %rax, %r15
movq 0x38(%rbx), %rsi
testq %r14, %r14
je 0xaa3c
movq 0x18(%r14), %rax
jmp 0xaa3e
xorl %eax, %eax
movq %rax, (%rsp)
pushq $0x1
popq %r8
movq %r15, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movl %ebp, %r9d
callq 0xa3fa
movq %r15, 0x18(%rbx)
movl $0xc0, %edi
callq 0x3240
movq %rax, %r15
movq 0x38(%rbx), %rsi
testq %r14, %r14
je 0xaa75
movq 0x20(%r14), %rax
jmp 0xaa77
xorl %eax, %eax
movq %rax, (%rsp)
pushq $0x1
popq %rcx
movq %r15, %rdi
xorl %edx, %edx
movl %ecx, %r8d
movl %ebp, %r9d
callq 0xa3fa
movq %r15, 0x20(%rbx)
movl $0xc0, %edi
callq 0x3240
movq %rax, %r15
movq 0x38(%rbx), %rsi
testq %r14, %r14
je 0xaaae
movq 0x28(%r14), %rax
jmp 0xaab0
xorl %eax, %eax
movq %rax, (%rsp)
pushq $0x2
popq %rcx
pushq $0x1
popq %r8
movq %r15, %rdi
xorl %edx, %edx
movl %ebp, %r9d
callq 0xa3fa
movq %r15, 0x28(%rbx)
movq (%rbx), %r12
movq 0x8(%rbx), %r13
leaq 0x8(%rsp), %r15
pushq $0x1
popq %rdx
pushq $0x3
popq %r14
pushq $0x2
popq %rbp
movq %r15, %rdi
xorl %esi, %esi
movl %r14d, %ecx
movl %ebp, %r8d
callq 0x6790
movq %r12, %rdi
movq %r13, %rsi
movl %r14d, %edx
movq %r15, %rcx
callq 0xa5d2
movq 0x8(%rbx), %r15
movq 0x10(%rbx), %r12
leaq 0x8(%rsp), %r13
movq %r13, %rdi
movl %r14d, %esi
pushq $0x1
popq %rdx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x6790
movq %r15, %rdi
movq %r12, %rsi
movl %r14d, %edx
movq %r13, %rcx
callq 0xa5d2
movq 0x18(%rbx), %r15
movq 0x20(%rbx), %r12
leaq 0x8(%rsp), %r13
movq %r13, %rdi
xorl %esi, %esi
movl %r14d, %edx
movl %ebp, %ecx
pushq $0x1
popq %r8
movl %r8d, %ebp
callq 0x6790
movq %r15, %rdi
movq %r12, %rsi
movl %r14d, %edx
movq %r13, %rcx
callq 0xa5d2
movq 0x20(%rbx), %r15
movq 0x28(%rbx), %r12
leaq 0x8(%rsp), %r13
movq %r13, %rdi
movl %r14d, %esi
movl %ebp, %edx
pushq $0x2
popq %rcx
xorl %r8d, %r8d
callq 0x6790
movq %r15, %rdi
movq %r12, %rsi
movl %r14d, %edx
movq %r13, %rcx
callq 0xa5d2
movq 0x8(%rbx), %r15
movq 0x18(%rbx), %r12
leaq 0x8(%rsp), %r13
movq %r13, %rdi
movl %ebp, %esi
xorl %edx, %edx
pushq $0x2
popq %rcx
movl %r14d, %r8d
callq 0x6790
movq %r15, %rdi
movq %r12, %rsi
movl %ebp, %edx
movq %r13, %rcx
callq 0xa5d2
movq 0x10(%rbx), %r15
movq 0x20(%rbx), %rbx
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movl %ebp, %esi
xorl %edx, %edx
pushq $0x2
popq %rcx
movl %r14d, %r8d
callq 0x6790
movq %r15, %rdi
movq %rbx, %rsi
movl %ebp, %edx
movq %r12, %rcx
callq 0xa5d2
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xac0e
jmp 0xac0e
jmp 0xac0e
jmp 0xac0e
movq %rax, %rbx
movl $0xc0, %esi
movq %r15, %rdi
callq 0x3250
movq %rbx, %rdi
callq 0x33d0
movq %rax, %rbx
movl $0xc0, %esi
movq %r12, %rdi
jmp 0xac19
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x3458
jmp 0xac1e
movq %rax, %rbx
jmp 0xac1e