// File: /workspace/github_cpp_makefile_star2_O1/pgrouchy[P]NoiseWorld/mathNet.cpp
// Function: Tree::reduceEqn()
void Tree::reduceEqn() {
    if (!this->isTerminal) {
        switch ((int)this->myVal) {
            case ADD: {
                this->leftTree->reduceEqn();
                this->rightTree->reduceEqn();
                if ((this->leftTree->isConstant) && (this->rightTree->isConstant)) { // reduce the addition of two constants to a single constant
                    this->myVal = this->leftTree->myVal + this->rightTree->myVal;
                    this->isConstant = true;
                    this->isTerminal = true;
                    delete this->leftTree;
                    delete this->rightTree;
                    this->leftTree = NULL;
                    this->rightTree = NULL;
                } else if (this->leftTree->isEqual(this->rightTree)) { // reduce the addition of two equal trees to 2x a single copy of that tree
                    this->myVal = MULTIPLY;
                    this->rightTree->myVal = 2.0;
                    this->rightTree->isConstant = true;
                    this->rightTree->isTerminal = true;
                    delete this->rightTree->leftTree;
                    this->rightTree->leftTree = NULL;
                    delete this->rightTree->rightTree;
                    this->rightTree->rightTree = NULL;
                }
                break;
            }
            case SUBTRACT: {
                this->leftTree->reduceEqn();
                this->rightTree->reduceEqn();
                if ((this->leftTree->isConstant) && (this->rightTree->isConstant)) { // reduce the subtraction of two constants to a single constant
                    this->myVal = this->leftTree->myVal - this->rightTree->myVal;
                    this->isConstant = true;
                    this->isTerminal = true;
                    delete this->leftTree;
                    delete this->rightTree;
                    this->leftTree = NULL;
                    this->rightTree = NULL;
                } else if (this->leftTree->isEqual(this->rightTree)) { // reduce the subtraction of two equal trees to 0
                    this->myVal = 0.0;
                    this->isConstant = true;
                    this->isTerminal = true;
                    delete this->leftTree;
                    delete this->rightTree;
                    this->leftTree = NULL;
                    this->rightTree = NULL;
                }
                break;
            }
            case MULTIPLY: {
                this->leftTree->reduceEqn();
                this->rightTree->reduceEqn();
                if ((this->leftTree->isConstant) && (this->rightTree->isConstant)) { // reduce the multiplication of two constants to a single constant
                    this->myVal = this->leftTree->myVal * this->rightTree->myVal;
                    this->isConstant = true;
                    this->isTerminal = true;
                    delete this->leftTree;
                    delete this->rightTree;
                    this->leftTree = NULL;
                    this->rightTree = NULL;
                } else if ((this->leftTree->isConstant) && ((int)this->leftTree->myVal == 0)) { // reduce the multiplication of a subtree by 0 to 0 (i.e., delete the subtree)
                    this->myVal = 0.0;
                    this->isConstant = true;
                    this->isTerminal = true;
                    delete this->leftTree;
                    delete this->rightTree;
                    this->leftTree = NULL;
                    this->rightTree = NULL;
                } else if ((this->rightTree->isConstant) && ((int)this->rightTree->myVal == 0)) { // reduce the multiplication of a subtree by 0 to 0 (i.e., delete the subtree)
                    this->myVal = 0.0;
                    this->isConstant = true;
                    this->isTerminal = true;
                    delete this->leftTree;
                    delete this->rightTree;
                    this->leftTree = NULL;
                    this->rightTree = NULL;
                }
                break;
            }
            case DIVIDE: {
                this->leftTree->reduceEqn();
                this->rightTree->reduceEqn();
                if ((this->leftTree->isConstant) && (this->rightTree->isConstant)) { // reduce the division of two constants to a single constant
                    if ((int)this->rightTree->myVal != 0) { // skip any division-by-zero operations, such agents will be selected to die after initial evaluation of EMM (see island.cpp)
                        this->myVal = this->leftTree->myVal / this->rightTree->myVal;
                        this->isConstant = true;
                        this->isTerminal = true;
                        delete this->leftTree;
                        delete this->rightTree;
                        this->leftTree = NULL;
                        this->rightTree = NULL;
                    }
                } else if ((this->leftTree->isConstant) && ((int)this->leftTree->myVal == 0)) { // reduce the division of 0 by a subtree to 0
                    this->myVal = 0.0;
                    this->isConstant = true;
                    this->isTerminal = true;
                    delete this->leftTree;
                    delete this->rightTree;
                    this->leftTree = NULL;
                    this->rightTree = NULL;
                }
                break;
            }
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
cmpl $0x0, 0x18(%rdi)
je 0x66d9
popq %rbx
popq %r14
popq %r15
retq
movq %rdi, %rbx
cvttsd2si 0x20(%rdi), %eax
cmpl $0x3, %eax
ja 0x66d3
leaq 0x4c27(%rip), %rcx      # 0xb314
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%rbx), %rdi
callq 0x66c8
movq 0x8(%rbx), %rdi
callq 0x66c8
movq (%rbx), %r14
cmpl $0x0, 0x1c(%r14)
je 0x681a
movq 0x8(%rbx), %rax
cmpl $0x0, 0x1c(%rax)
je 0x681a
movsd 0x20(%r14), %xmm0
addsd 0x20(%rax), %xmm0
jmp 0x67f9
movq (%rbx), %rdi
callq 0x66c8
movq 0x8(%rbx), %rdi
callq 0x66c8
movq (%rbx), %r14
movl 0x1c(%r14), %eax
testl %eax, %eax
je 0x6920
movq 0x8(%rbx), %rcx
cmpl $0x0, 0x1c(%rcx)
je 0x6912
movsd 0x20(%r14), %xmm0
mulsd 0x20(%rcx), %xmm0
jmp 0x67f9
movq (%rbx), %rdi
callq 0x66c8
movq 0x8(%rbx), %rdi
callq 0x66c8
movq (%rbx), %r14
movl 0x1c(%r14), %eax
testl %eax, %eax
je 0x66d3
movq 0x8(%rbx), %rcx
cmpl $0x0, 0x1c(%rcx)
je 0x6935
movsd 0x20(%rcx), %xmm0
cvttsd2si %xmm0, %eax
testl %eax, %eax
je 0x66d3
movsd 0x20(%r14), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rbx)
jmp 0x67fe
movq (%rbx), %rdi
callq 0x66c8
movq 0x8(%rbx), %rdi
callq 0x66c8
movq (%rbx), %r14
cmpl $0x0, 0x1c(%r14)
je 0x68a8
movq 0x8(%rbx), %rax
cmpl $0x0, 0x1c(%rax)
je 0x68a8
movsd 0x20(%r14), %xmm0
subsd 0x20(%rax), %xmm0
movsd %xmm0, 0x20(%rbx)
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x18(%rbx)
testq %r14, %r14
jne 0x68d2
jmp 0x68e7
movq 0x8(%rbx), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x6958
testb %al, %al
je 0x66d3
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
movq %rax, 0x20(%rbx)
movq %rax, 0x20(%r15)
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x18(%r15)
movq (%r15), %r14
testq %r14, %r14
je 0x686e
movq %r14, %rdi
callq 0x5afe
movl $0x38, %esi
movq %r14, %rdi
callq 0x21f0
movq 0x8(%rbx), %rax
movq $0x0, (%rax)
movq 0x8(%rax), %r14
testq %r14, %r14
je 0x6897
movq %r14, %rdi
callq 0x5afe
movl $0x38, %esi
movq %r14, %rdi
callq 0x21f0
movq 0x8(%rbx), %rax
movq $0x0, 0x8(%rax)
jmp 0x66d3
movq 0x8(%rbx), %rsi
movq %r14, %rdi
callq 0x6958
testb %al, %al
je 0x66d3
movq $0x0, 0x20(%rbx)
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x18(%rbx)
movq %r14, %rdi
callq 0x5afe
movl $0x38, %esi
movq %r14, %rdi
callq 0x21f0
movq 0x8(%rbx), %r14
testq %r14, %r14
je 0x6905
movq %r14, %rdi
callq 0x5afe
movl $0x38, %esi
movq %r14, %rdi
callq 0x21f0
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
jmp 0x66d3
testl %eax, %eax
je 0x6920
cvttsd2si 0x20(%r14), %eax
testl %eax, %eax
je 0x694b
movq 0x8(%rbx), %rax
cmpl $0x0, 0x1c(%rax)
je 0x66d3
cvttsd2si 0x20(%rax), %eax
jmp 0x6943
testl %eax, %eax
je 0x66d3
cvttsd2si 0x20(%r14), %eax
testl %eax, %eax
jne 0x66d3
movq $0x0, 0x20(%rbx)
jmp 0x67fe