// File: /workspace/github_cpp_makefile_star2_O3/joncampbell123[P]haxcc/haxpp.cpp
// Function: pp_if_eval(expression&, unsigned long)
signed long long pp_if_eval(expression &expr,expression::node::node_t node) {
    if (node == expression::node::none)
        throw invalid_argument("expression tree with no root");

    const auto &n = expr.getnode(node);
    switch (n.tval.tval) {
        case token::INTEGER:
            return n.tval.i.s;
        case token::FLOAT:
            throw invalid_argument("Floating point not allowed in expressions at preprocessor level");
        case token::STRING:
            throw invalid_argument("Strings not allowed in expressions at preprocessor level");
        case token::ASSIGNMENT:
            throw invalid_argument("Assignment not permitted in macro preprocessor");
        case token::POSTINCREMENT:
        case token::POSTDECREMENT:
        case token::PREINCREMENT:
        case token::PREDECREMENT:
            throw invalid_argument("increment/decrement not allowed in macro preprocessor");
        case token::DEREFERENCE:
        case token::STRUCTREF:
        case token::ADDRESSOF:
            throw invalid_argument("struct/pointer ref not allowed in macro preprocessor");
        case token::SIZEOF:
            throw invalid_argument("sizeof not allowed in macro preprocessor");
        case token::COMMA:
            return pp_if_eval(expr,n.children.at(1)); /* a,b -> b */
        case token::PLUS:
            if (n.children.size() == 2)
                return pp_if_eval(expr,n.children.at(0)) + pp_if_eval(expr,n.children.at(1));
            else if (n.children.size() == 1)
                return pp_if_eval(expr,n.children.at(0)); /* +a -> a */
        case token::NEGATE:
            return -pp_if_eval(expr,n.children.at(0));
        case token::MINUS:
            return pp_if_eval(expr,n.children.at(0)) - pp_if_eval(expr,n.children.at(1));
        case token::NOT:
            return (pp_if_eval(expr,n.children.at(0)) == 0) ? 1 : 0;
        case token::COMPLEMENT:
            return ~pp_if_eval(expr,n.children.at(0));
        case token::MULTIPLY:
            return pp_if_eval(expr,n.children.at(0)) * pp_if_eval(expr,n.children.at(1));
        case token::DIVISION:
            return pp_if_eval(expr,n.children.at(0)) / pp_if_eval(expr,n.children.at(1));
        case token::MODULUS:
            return pp_if_eval(expr,n.children.at(0)) % pp_if_eval(expr,n.children.at(1));
        case token::LOGICAL_AND:
            return ((pp_if_eval(expr,n.children.at(0)) != 0ll) && (pp_if_eval(expr,n.children.at(1)) != 0ll)) ? 1 : 0;
        case token::LOGICAL_OR:
            return ((pp_if_eval(expr,n.children.at(0)) != 0ll) || (pp_if_eval(expr,n.children.at(1)) != 0ll)) ? 1 : 0;
        case token::BINARY_AND:
            return pp_if_eval(expr,n.children.at(0)) & pp_if_eval(expr,n.children.at(1));
        case token::BINARY_XOR:
            return pp_if_eval(expr,n.children.at(0)) ^ pp_if_eval(expr,n.children.at(1));
        case token::BINARY_OR:
            return pp_if_eval(expr,n.children.at(0)) | pp_if_eval(expr,n.children.at(1));
        case token::EQUALS:
            return (pp_if_eval(expr,n.children.at(0)) == pp_if_eval(expr,n.children.at(1))) ? 1 : 0;
        case token::NOT_EQUALS:
            return (pp_if_eval(expr,n.children.at(0)) != pp_if_eval(expr,n.children.at(1))) ? 1 : 0;
        case token::LESS_THAN:
            return (pp_if_eval(expr,n.children.at(0)) < pp_if_eval(expr,n.children.at(1))) ? 1 : 0;
        case token::LESS_THAN_OR_EQUAL:
            return (pp_if_eval(expr,n.children.at(0)) <= pp_if_eval(expr,n.children.at(1))) ? 1 : 0;
        case token::GREATER_THAN:
            return (pp_if_eval(expr,n.children.at(0)) > pp_if_eval(expr,n.children.at(1))) ? 1 : 0;
        case token::GREATER_THAN_OR_EQUAL:
            return (pp_if_eval(expr,n.children.at(0)) >= pp_if_eval(expr,n.children.at(1))) ? 1 : 0;
        case token::TERNARY:
            return (pp_if_eval(expr,n.children.at(0)) != 0ll) ?
                    pp_if_eval(expr,n.children.at(1)) :
                    pp_if_eval(expr,n.children.at(2));
        case token::IDENTIFIER:
            return 0ll; /* if the macro expansion did not replace the identifier with a value then it is zero */
        case token::DEFINED:
            {
                const auto &c = expr.getnode(n.children.at(0));
                if (c.tval.tval == token::IDENTIFIER)
                    return is_macro(c.tval.sval) ? 1 : 0;
                else
                    throw invalid_argument("defined() used with a non-identifier");
            }
        case token::TYPECAST: /* .at(0)=type tokens .at(1)=expression to typecast */
            fprintf(stderr,"WARNING: Typecasts are ignored by the macro processor\n");
            return pp_if_eval(expr,n.children.at(n.children.size()-size_t(1)));
        default:
            break;
    };

    throw invalid_argument(string("unsupported expression in preprocessor level, token ")+to_string(n.tval));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
cmpq $-0x1, %rsi
je 0xcc07
movq %rsi, %rcx
movq %rdi, %rbx
xorl %r13d, %r13d
movabsq $-0x71c71c71c71c71c7, %r12 # imm = 0x8E38E38E38E38E39
leaq 0x6f41(%rip), %rbp      # 0x13484
movq (%rbx), %rsi
movq 0x8(%rbx), %rax
subq %rsi, %rax
sarq $0x4, %rax
imulq %r12, %rax
cmpq %rcx, %rax
jbe 0xcbd8
leaq (%rcx,%rcx,8), %rcx
shlq $0x4, %rcx
leaq (%rsi,%rcx), %r14
movl (%rsi,%rcx), %ecx
leal -0x5(%rcx), %edx
cmpl $0x3f, %edx
ja 0xc5d2
movslq (%rbp,%rdx,4), %rax
addq %rbp, %rax
jmpq *%rax
movq 0x70(%r14), %rcx
movq 0x78(%r14), %rax
movq %rax, %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
je 0xc635
cmpq $0x2, %rdx
jne 0xc7dc
movq (%rcx), %rsi
movq %rbx, %rdi
callq 0xc511
movq 0x70(%r14), %rcx
movq 0x78(%r14), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
jbe 0xcc49
movq 0x8(%rcx), %rcx
addq %rax, %r13
jmp 0xc638
cmpl $0x7e, %ecx
jne 0xc65c
movq 0x70(%r14), %rax
cmpq %rax, 0x78(%r14)
je 0xcc57
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq 0x70(%r14), %rcx
movq 0x78(%r14), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
testq %rax, %rax
jne 0xc627
cmpq $0x2, %rdx
jbe 0xcd6d
addq $0x10, %rcx
jmp 0xc635
movq 0x70(%r14), %rcx
movq 0x78(%r14), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
jbe 0xcc49
addq $0x8, %rcx
movq (%rcx), %rcx
cmpq $-0x1, %rcx
jne 0xc543
jmp 0xcc07
leaq 0x28(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2428
movq (%r15), %rcx
jmp 0xc635
cmpl $0x63, %ecx
jne 0xcc69
movq 0x70(%r14), %rcx
cmpq %rcx, 0x78(%r14)
je 0xcc57
movq (%rcx), %rcx
cmpq %rax, %rcx
jae 0xcd7e
leaq (%rcx,%rcx,8), %rax
shlq $0x4, %rax
cmpl $0x5, (%rsi,%rax)
jne 0xcd9f
addq %rax, %rsi
addq $0x48, %rsi
leaq 0xdb71(%rip), %rdi      # 0x1a210
callq 0x10bc4
leaq 0xdb6d(%rip), %rcx      # 0x1a218
xorl %r15d, %r15d
cmpq %rcx, %rax
setne %r15b
jmp 0xcae2
movq 0x70(%r14), %rax
cmpq %rax, 0x78(%r14)
je 0xcc57
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq %rax, %r12
movq 0x70(%r14), %rax
movq 0x78(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
jbe 0xcc49
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq %rax, %r15
orq %r12, %r15
jmp 0xcae2
movq 0x70(%r14), %rax
cmpq %rax, 0x78(%r14)
je 0xcc57
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xc511
cmpq $0x1, %rax
adcq $0x0, %r13
jmp 0xcb81
movq 0x70(%r14), %rax
cmpq %rax, 0x78(%r14)
je 0xcc57
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq %rax, %r15
movq 0x70(%r14), %rax
movq 0x78(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
jbe 0xcc49
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq %rax, %rcx
movq %r15, %rax
cqto
idivq %rcx
movq %rax, %r15
jmp 0xcae2
movq 0x70(%r14), %rax
cmpq %rax, 0x78(%r14)
je 0xcc57
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq %rax, %r15
movq 0x70(%r14), %rax
movq 0x78(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
jbe 0xcc49
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq %rax, %rcx
movq %r15, %rax
cqto
idivq %rcx
movq %rdx, %r15
jmp 0xcae2
movq 0x70(%r14), %rcx
movq 0x78(%r14), %rax
cmpq %rcx, %rax
je 0xcc57
movq (%rcx), %rsi
movq %rbx, %rdi
callq 0xc511
subq %rax, %r13
jmp 0xcb81
movq 0x70(%r14), %rax
cmpq %rax, 0x78(%r14)
je 0xcc57
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq %rax, %r15
movq 0x70(%r14), %rax
movq 0x78(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
jbe 0xcc49
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xc511
xorl %ecx, %ecx
cmpq %rax, %r15
setge %cl
jmp 0xcb7e
movq 0x70(%r14), %rax
cmpq %rax, 0x78(%r14)
je 0xcc57
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xc511
testq %rax, %rax
jne 0xc894
xorl %r15d, %r15d
jmp 0xcae2
movq 0x70(%r14), %rax
cmpq %rax, 0x78(%r14)
je 0xcc57
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movl $0x1, %r15d
testq %rax, %rax
jne 0xcae2
movq 0x70(%r14), %rax
movq 0x78(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
jbe 0xcc49
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xc511
cmpq $0x1, %rax
sbbq $-0x1, %r13
jmp 0xcb81
movq 0x70(%r14), %rax
cmpq %rax, 0x78(%r14)
je 0xcc57
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq %rax, %r15
movq 0x70(%r14), %rax
movq 0x78(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
jbe 0xcc49
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xc511
xorl %ecx, %ecx
cmpq %rax, %r15
setle %cl
jmp 0xcb7e
movq 0x70(%r14), %rax
cmpq %rax, 0x78(%r14)
je 0xcc57
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq %rax, %r12
movq 0x70(%r14), %rax
movq 0x78(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
jbe 0xcc49
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq %rax, %r15
imulq %r12, %r15
jmp 0xcae2
movq 0x70(%r14), %rax
cmpq %rax, 0x78(%r14)
je 0xcc57
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq %rax, %r15
movq 0x70(%r14), %rax
movq 0x78(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
jbe 0xcc49
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xc511
xorl %ecx, %ecx
cmpq %rax, %r15
setg %cl
jmp 0xcb7e
movq 0x70(%r14), %rax
cmpq %rax, 0x78(%r14)
je 0xcc57
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq %rax, %r12
movq 0x70(%r14), %rax
movq 0x78(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
jbe 0xcc49
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq %rax, %r15
xorq %r12, %r15
jmp 0xcae2
movq 0x70(%r14), %rax
cmpq %rax, 0x78(%r14)
je 0xcc57
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq %rax, %r15
movq 0x70(%r14), %rax
movq 0x78(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
jbe 0xcc49
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xc511
addq %r13, %r15
subq %rax, %r15
jmp 0xcb84
movq 0x70(%r14), %rax
cmpq %rax, 0x78(%r14)
je 0xcc57
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq %rax, %r15
movq 0x70(%r14), %rax
movq 0x78(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
jbe 0xcc49
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xc511
xorl %ecx, %ecx
cmpq %rax, %r15
sete %cl
jmp 0xcb7e
movq 0x70(%r14), %rax
cmpq %rax, 0x78(%r14)
je 0xcc57
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq %rax, %r12
movq 0x70(%r14), %rax
movq 0x78(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
jbe 0xcc49
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq %rax, %r15
andq %r12, %r15
jmp 0xcae2
movq 0x8(%r14), %r15
addq %r13, %r15
jmp 0xcb84
movq 0x70(%r14), %rax
cmpq %rax, 0x78(%r14)
je 0xcc57
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq %rax, %r15
movq 0x70(%r14), %rax
movq 0x78(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
jbe 0xcc49
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xc511
xorl %ecx, %ecx
cmpq %rax, %r15
setl %cl
jmp 0xcb7e
movq 0x70(%r14), %rax
cmpq %rax, 0x78(%r14)
je 0xcc57
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xc511
movq %rax, %r15
movq 0x70(%r14), %rax
movq 0x78(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
jbe 0xcc49
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xc511
xorl %ecx, %ecx
cmpq %rax, %r15
setne %cl
addq %rcx, %r13
movq %r13, %r15
movq %r15, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x70(%r14), %rax
cmpq %rax, 0x78(%r14)
je 0xcc57
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xc511
notq %rax
addq %rax, %r13
jmp 0xcb81
movl $0x10, %edi
callq 0x20e0
movq %rax, %r14
leaq 0x77a0(%rip), %rsi      # 0x1436b
movq %rax, %rdi
callq 0x23a0
jmp 0xcd57
movl $0x10, %edi
callq 0x20e0
movq %rax, %r14
leaq 0x7b5b(%rip), %rsi      # 0x14747
movq %rax, %rdi
callq 0x20b0
movq 0xd3fd(%rip), %rsi      # 0x19ff8
movq 0xd3ae(%rip), %rdx      # 0x19fb0
jmp 0xcd65
movl $0x10, %edi
callq 0x20e0
movq %rax, %r14
leaq 0x768b(%rip), %rsi      # 0x142a6
movq %rax, %rdi
callq 0x23a0
jmp 0xcd57
movl $0x10, %edi
callq 0x20e0
movq %rax, %r14
leaq 0x7765(%rip), %rsi      # 0x143a1
movq %rax, %rdi
callq 0x23a0
jmp 0xcd57
leaq 0x7c94(%rip), %rdi      # 0x148e4
movl $0x1, %esi
jmp 0xcc62
leaq 0x7c86(%rip), %rdi      # 0x148e4
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x22a0
movl $0x10, %edi
callq 0x20e0
movq %rax, %r15
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x77d4(%rip), %rsi      # 0x1445b
leaq 0x7801(%rip), %rdx      # 0x1448f
leaq 0x8(%rsp), %rdi
callq 0x10b2e
leaq 0x48(%rsp), %rdi
movq %r14, %rsi
callq 0x50ff
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x48(%rsp), %rdx
callq 0xee77
movb $0x1, %bpl
leaq 0x28(%rsp), %rsi
movq %r15, %rdi
callq 0x2350
xorl %ebp, %ebp
movq 0xd306(%rip), %rsi      # 0x19fd8
movq 0xd2e7(%rip), %rdx      # 0x19fc0
movq %r15, %rdi
callq 0x2330
movl $0x10, %edi
callq 0x20e0
movq %rax, %r14
leaq 0x76e1(%rip), %rsi      # 0x143d6
movq %rax, %rdi
callq 0x23a0
jmp 0xcd57
movl $0x10, %edi
callq 0x20e0
movq %rax, %r14
leaq 0x75f0(%rip), %rsi      # 0x14303
movq %rax, %rdi
callq 0x23a0
jmp 0xcd57
movl $0x10, %edi
callq 0x20e0
movq %rax, %r14
leaq 0x7592(%rip), %rsi      # 0x142c3
movq %rax, %rdi
callq 0x23a0
jmp 0xcd57
movl $0x10, %edi
callq 0x20e0
movq %rax, %r14
leaq 0x75ed(%rip), %rsi      # 0x1433c
movq %rax, %rdi
callq 0x23a0
movq 0xd27a(%rip), %rsi      # 0x19fd8
movq 0xd25b(%rip), %rdx      # 0x19fc0
movq %r14, %rdi
callq 0x2330
leaq 0x7b70(%rip), %rdi      # 0x148e4
movl $0x2, %esi
jmp 0xcc62
movl $0x10, %edi
callq 0x20e0
movq %rax, %r14
leaq 0x79b5(%rip), %rsi      # 0x14747
movq %rax, %rdi
callq 0x20b0
jmp 0xcbf4
movl $0x10, %edi
callq 0x20e0
movq %rax, %r14
leaq 0x764c(%rip), %rsi      # 0x143ff
movq %rax, %rdi
callq 0x23a0
jmp 0xcd57
jmp 0xce58
jmp 0xce58
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xcded
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21d0
jmp 0xcded
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xce08
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21d0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xce1f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21d0
testb %bpl, %bpl
jne 0xce4d
jmp 0xce63
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xce4d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21d0
jmp 0xce4d
jmp 0xce58
jmp 0xce58
jmp 0xce58
jmp 0xce58
movq %rax, %rbx
movq %r15, %rdi
jmp 0xce5e
jmp 0xce58
jmp 0xce58
jmp 0xce58
movq %rax, %rbx
movq %r14, %rdi
callq 0x2160
movq %rbx, %rdi
callq 0x2360