// File: MarkCBell[P]twister/./twister/kernel/twister.cpp
// Function: tetra::tetra(manifold*, Category, Position, Side, int, tetra*)
tetra::tetra(manifold *M, Category mycategory, Position myposition, Side myside, int mylayer, tetra *my_parent)
{
	output_debugging("tet", 3);
	
	for (int i = 0; i < 4; i++)
		gluedto[i] = NULL;
	
	// There's nothing canonical to put in gluing[],
	// so we put in the identity permutation.
	for (int i = 0; i < 4; i++)
		gluing[i] = perm(1,0,2,3);
	
	next = NULL;
	prev = NULL;
	
	parent = my_parent;
	if (my_parent != NULL) my_parent->child = this;
	child = NULL;
	
	M->onemore(this);  // Add this new tetra to the doubly linked list of tetras.
	
	category = mycategory;
	position = myposition;
	side = myside;
	layer = mylayer;
	
	snap_index = -1;  // Index only determined when snap_print is called.
	cusp_number = -1;  // The cusp number of vertex 3 because vertices 0, 1 and 2 are always material.
	temp = -1;
	for (int i = 0; i < 4; i++)
	{
		peripheral_curves[longitude][i] = 0;
		peripheral_curves[meridian][i] = 0;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl %r9d, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x88(%rbp)
addq $0x30, %rax
movq %rax, %rcx
addq $0x40, %rcx
movq %rcx, -0x80(%rbp)
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0x16ea0
movq -0x90(%rbp), %rax
movq -0x80(%rbp), %rcx
addq $0x10, %rax
cmpq %rcx, %rax
movq %rax, -0x78(%rbp)
jne 0x170b3
leaq -0x41(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x3560
movq -0x98(%rbp), %rdx
leaq 0x10385(%rip), %rsi     # 0x2747e
leaq -0x40(%rbp), %rdi
callq 0x4e10
jmp 0x17104
leaq -0x40(%rbp), %rdi
movl $0x3, %esi
callq 0x4c10
jmp 0x17114
leaq -0x40(%rbp), %rdi
callq 0x35f8
leaq -0x41(%rbp), %rdi
callq 0x3360
movl $0x0, -0x58(%rbp)
cmpl $0x4, -0x58(%rbp)
jge 0x17183
movq -0x88(%rbp), %rax
movslq -0x58(%rbp), %rcx
movq $0x0, 0x10(%rax,%rcx,8)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x1712d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x17175
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 0x172b6
movl $0x0, -0x5c(%rbp)
cmpl $0x4, -0x5c(%rbp)
jge 0x171db
leaq -0x6c(%rbp), %rdi
movl $0x1, %esi
xorl %edx, %edx
movl $0x2, %ecx
movl $0x3, %r8d
callq 0x9cc0
movq -0x88(%rbp), %rax
addq $0x30, %rax
movslq -0x5c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq -0x6c(%rbp), %rcx
movq %rcx, (%rax)
movq -0x64(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x1718a
movq -0x88(%rbp), %rax
movq $0x0, (%rax)
movq $0x0, 0x8(%rax)
movq 0x10(%rbp), %rcx
movq %rcx, 0x80(%rax)
cmpq $0x0, 0x10(%rbp)
je 0x17215
movq -0x88(%rbp), %rcx
movq 0x10(%rbp), %rax
movq %rcx, 0x88(%rax)
movq -0x88(%rbp), %rsi
movq $0x0, 0x88(%rsi)
movq -0x10(%rbp), %rdi
callq 0x172c0
movq -0x88(%rbp), %rax
movl -0x14(%rbp), %ecx
movl %ecx, 0x70(%rax)
movl -0x18(%rbp), %ecx
movl %ecx, 0x74(%rax)
movl -0x1c(%rbp), %ecx
movl %ecx, 0x78(%rax)
movl -0x20(%rbp), %ecx
movl %ecx, 0x90(%rax)
movl $0xffffffff, 0xbc(%rax) # imm = 0xFFFFFFFF
movl $0xffffffff, 0xb4(%rax) # imm = 0xFFFFFFFF
movl $0xffffffff, 0xb8(%rax) # imm = 0xFFFFFFFF
movl $0x0, -0x70(%rbp)
cmpl $0x4, -0x70(%rbp)
jge 0x172ad
movq -0x88(%rbp), %rax
movslq -0x70(%rbp), %rcx
movl $0x0, 0x94(%rax,%rcx,4)
movslq -0x70(%rbp), %rcx
movl $0x0, 0xa4(%rax,%rcx,4)
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x17277
addq $0xa0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x3550
nop