// File: /workspace/github_cpp_makefile_star2_O2/joncampbell123[P]haxcc/haxpp.cpp
// Function: parse_expr_typecast(expression&, __gnu_cxx::__normal_iterator<token*, std::vector<token, std::allocator<token>>>&, __gnu_cxx::__normal_iterator<token*, std::vector<token, std::allocator<token>>> const&, bool)
expression::node::node_t parse_expr_typecast(expression &expr,token_string::iterator &ti,const token_string::iterator &tie,const bool exprfollow=true) {
    token::token_t repl;
    auto tmpti = ti;

    if (tmpti != tie && (*tmpti).tval == token::OPEN_PARENS) {
        tmpti++;
        if (tmpti != tie && is_type_token(/*&*/repl,*tmpti)) {
            ti = tmpti;

            const expression::node::node_t opnode = expr.newnode(exprfollow ? token::TYPECAST : token::TYPESPEC);

            /* NTS: Treat LOGICAL_AND as if two ADDRESSOF so && works properly here */
            while (ti != tie && (is_type_token(/*&*/repl,*ti) || (*ti).tval == token::LOGICAL_AND)) {
                if ((*ti).tval == token::LOGICAL_AND) {
                    expr.getnode(opnode).children.push_back(expr.newnode(token::ADDRESSOF));
                    expr.getnode(opnode).children.push_back(expr.newnode(token::ADDRESSOF));
                    ti++;
                }
                else {
                    expr.getnode(opnode).children.push_back(expr.newnode(*(ti++),repl));
                }
            }

            if (ti == tie)
                throw invalid_argument("missing closing parens");
            if ((*ti).tval != token::CLOSE_PARENS)
                throw invalid_argument("missing closing parens");
            ti++;

            if (exprfollow)
                expr.getnode(opnode).children.push_back(parse_expr(expr,ti,tie));

            return opnode;
        }
    }

    return expression::node::none;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq (%rsi), %r13
movq %rdx, 0x28(%rsp)
movq (%rdx), %rax
pushq $-0x1
popq %r12
cmpq %r13, %rax
je 0x9300
cmpl $0x20, (%r13)
jne 0x9300
addq $0x70, %r13
cmpq %rax, %r13
je 0x9300
movl %ecx, %ebx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x14(%rsp), %rdi
movq %r13, %rsi
callq 0x9025
testb %al, %al
je 0x9300
movq %r13, (%r14)
movl %ebx, 0x24(%rsp)
movzbl %bl, %eax
pushq $0x8
popq %rcx
subl %eax, %ecx
leaq 0x78(%rsp), %r12
movl %ecx, -0x48(%r12)
xorl %eax, %eax
movb %al, -0x44(%r12)
andq $0x0, -0x40(%r12)
movb $0x1, -0x38(%r12)
fldz
fstpt 0x50(%rsp)
andl $0x0, -0x18(%r12)
orq $-0x1, -0x8(%r12)
leaq 0x88(%rsp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x30(%rsp), %rsi
movq %r15, %rdi
callq 0x8794
movq %rax, %r13
movq %r12, %rdi
callq 0x2408
leaq 0x8(%rsp), %rax
movq %r13, (%rax)
leaq 0x30(%rsp), %r13
xorl %ebx, %ebx
movq (%r14), %r12
movq 0x28(%rsp), %rax
movq (%rax), %rbp
cmpq %rbp, %r12
je 0x9315
leaq 0x14(%rsp), %rdi
movq %r12, %rsi
callq 0x9025
movl (%r12), %ecx
testb %al, %al
je 0x9197
cmpl $0x43, %ecx
je 0x91a0
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0xb4a6
leaq 0x70(%rax), %r12
movq (%r14), %rsi
leaq 0x70(%rsi), %rax
movq %rax, (%r14)
movl 0x14(%rsp), %edx
movq %r15, %rdi
callq 0x87e0
movq %rax, 0x30(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0xdc9a
jmp 0x9130
cmpl $0x43, %ecx
jne 0x92a9
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0xb4a6
movq %rax, %r12
movl $0x16, 0x30(%rsp)
movb %bl, 0x34(%rsp)
andq $0x0, 0x38(%rsp)
movb $0x1, 0x40(%rsp)
fldz
fstpt 0x50(%rsp)
andl $0x0, 0x60(%rsp)
orq $-0x1, 0x70(%rsp)
leaq 0x88(%rsp), %rax
movq %rax, 0x78(%rsp)
andq $0x0, 0x80(%rsp)
movb %bl, 0x88(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x8794
addq $0x70, %r12
movq %rax, 0x18(%rsp)
movq %r12, %rdi
leaq 0x18(%rsp), %rsi
callq 0xdc9a
leaq 0x78(%rsp), %rdi
callq 0x2408
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0xb4a6
movq %rax, %r12
movl $0x16, 0x30(%rsp)
movb %bl, 0x34(%rsp)
andq $0x0, 0x38(%rsp)
movb $0x1, 0x40(%rsp)
fldz
fstpt 0x50(%rsp)
andl $0x0, 0x60(%rsp)
orq $-0x1, 0x70(%rsp)
leaq 0x88(%rsp), %rax
movq %rax, 0x78(%rsp)
andq $0x0, 0x80(%rsp)
movb %bl, 0x88(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x8794
addq $0x70, %r12
movq %rax, 0x18(%rsp)
movq %r12, %rdi
leaq 0x18(%rsp), %rsi
callq 0xdc9a
leaq 0x78(%rsp), %rdi
callq 0x2408
addq $0x70, (%r14)
jmp 0x9130
cmpq %rbp, %r12
je 0x9315
cmpl $0x21, (%r12)
jne 0x9345
addq $0x70, %r12
movq %r12, (%r14)
cmpb $0x0, 0x24(%rsp)
je 0x92fb
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0xb4a6
leaq 0x70(%rax), %r12
pushq $-0x1
popq %rcx
movq %r15, %rdi
movq %r14, %rsi
movq 0x28(%rsp), %rdx
callq 0x895f
leaq 0x30(%rsp), %rsi
movq %rax, (%rsi)
movq %r12, %rdi
callq 0xdc9a
movq 0x8(%rsp), %r12
movq %r12, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x20e0
movq %rax, %r14
leaq 0x6f11(%rip), %rsi      # 0x10238
movq %rax, %rdi
callq 0x23a0
movq 0xeca2(%rip), %rsi      # 0x17fd8
movq 0xec83(%rip), %rdx      # 0x17fc0
movq %r14, %rdi
callq 0x2340
pushq $0x10
popq %rdi
callq 0x20e0
movq %rax, %r14
leaq 0x6ee1(%rip), %rsi      # 0x10238
movq %rax, %rdi
callq 0x23a0
jmp 0x932f
jmp 0x936b
movq %rax, %rbx
movq %r12, %rdi
jmp 0x9382
movq %rax, %rbx
movq %r14, %rdi
callq 0x2160
jmp 0x9387
jmp 0x937a
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x2408
movq %rbx, %rdi
callq 0x2370