// File: pgrouchy[P]NoiseWorld/mathNet.cpp
// Function: Tree::evalEquation(double*, int)
double Tree::evalEquation(double currentData[], int current_num_trees) {
    double myResult = 0.0;

    if (this->isTerminal) {
        if (this->isConstant) {
            myResult = this->myVal;
        } else {
            myResult = currentData[(int)this->myVal];
        }
    } else {
        switch ((int)this->myVal) {
            case ADD: {
                myResult = this->leftTree->evalEquation(currentData, current_num_trees) + this->rightTree->evalEquation(currentData, current_num_trees);
                break;
            }
            case SUBTRACT: {
                myResult = this->leftTree->evalEquation(currentData, current_num_trees) - this->rightTree->evalEquation(currentData, current_num_trees);
                break;
            }
            case MULTIPLY: {
                myResult = this->leftTree->evalEquation(currentData, current_num_trees) * this->rightTree->evalEquation(currentData, current_num_trees);
                break;
            }
            case DIVIDE: {
                myResult = this->leftTree->evalEquation(currentData, current_num_trees) / this->rightTree->evalEquation(currentData, current_num_trees);
                break;
            }
        }
    }

    return myResult;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movl %edx, 0x44(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x30(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
cmpl $0x0, 0x18(%rax)
je 0xafea
movq 0x30(%rsp), %rax
cmpl $0x0, 0x1c(%rax)
je 0xafc8
movq 0x30(%rsp), %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
jmp 0xafe5
movq 0x30(%rsp), %rcx
movq 0x48(%rsp), %rax
cvttsd2si 0x20(%rcx), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x38(%rsp)
jmp 0xb13f
movq 0x30(%rsp), %rax
cvttsd2si 0x20(%rax), %eax
movl %eax, %ecx
movq %rcx, 0x28(%rsp)
subl $0x3, %eax
ja 0xb13d
movq 0x28(%rsp), %rax
leaq 0xa1e8(%rip), %rcx      # 0x151f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x30(%rsp), %rax
movq (%rax), %rdi
movq 0x48(%rsp), %rsi
movl 0x44(%rsp), %edx
callq 0xaf80
movq 0x30(%rsp), %rax
movsd %xmm0, 0x20(%rsp)
movq 0x8(%rax), %rdi
movq 0x48(%rsp), %rsi
movl 0x44(%rsp), %edx
callq 0xaf80
movaps %xmm0, %xmm1
movsd 0x20(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
jmp 0xb13d
movq 0x30(%rsp), %rax
movq (%rax), %rdi
movq 0x48(%rsp), %rsi
movl 0x44(%rsp), %edx
callq 0xaf80
movq 0x30(%rsp), %rax
movsd %xmm0, 0x18(%rsp)
movq 0x8(%rax), %rdi
movq 0x48(%rsp), %rsi
movl 0x44(%rsp), %edx
callq 0xaf80
movaps %xmm0, %xmm1
movsd 0x18(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
jmp 0xb13d
movq 0x30(%rsp), %rax
movq (%rax), %rdi
movq 0x48(%rsp), %rsi
movl 0x44(%rsp), %edx
callq 0xaf80
movq 0x30(%rsp), %rax
movsd %xmm0, 0x10(%rsp)
movq 0x8(%rax), %rdi
movq 0x48(%rsp), %rsi
movl 0x44(%rsp), %edx
callq 0xaf80
movaps %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
jmp 0xb13d
movq 0x30(%rsp), %rax
movq (%rax), %rdi
movq 0x48(%rsp), %rsi
movl 0x44(%rsp), %edx
callq 0xaf80
movq 0x30(%rsp), %rax
movsd %xmm0, 0x8(%rsp)
movq 0x8(%rax), %rdi
movq 0x48(%rsp), %rsi
movl 0x44(%rsp), %edx
callq 0xaf80
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
jmp 0xb13f
movsd 0x38(%rsp), %xmm0
addq $0x58, %rsp
retq
nopw (%rax,%rax)