// File: /workspace/github_cpp_makefile_star2_O1/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, 0x18(%rsp)
movq (%rdx), %rax
movq $-0x1, %rbx
cmpq %r13, %rax
je 0xc017
cmpl $0x20, (%r13)
jne 0xc017
addq $0x70, %r13
cmpq %rax, %r13
je 0xc017
movl %ecx, %ebp
movq %rsi, %r15
movq %rdi, %r12
leaq 0xc(%rsp), %rdi
movq %r13, %rsi
callq 0xbbef
testb %al, %al
je 0xc017
movq %r13, (%r15)
movzbl %bpl, %eax
movl $0x8, %ecx
subl %eax, %ecx
leaq 0x88(%rsp), %r14
movl %ecx, -0x58(%r14)
xorl %eax, %eax
movb %al, -0x54(%r14)
movq %rax, -0x50(%r14)
movb $0x1, -0x48(%r14)
fldz
fstpt 0x50(%rsp)
movl $0x0, -0x28(%r14)
movq $-0x1, -0x18(%r14)
movq %r14, -0x10(%r14)
movq %rax, -0x8(%r14)
movb %al, (%r14)
leaq 0x30(%rsp), %rsi
movq %r12, %rdi
callq 0xae2e
movq %rax, %rbx
movl %ebp, 0x2c(%rsp)
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
je 0xbd07
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x21d0
movq (%r15), %r13
movq 0x18(%rsp), %rax
movq (%rax), %rbp
cmpq %rbp, %r13
je 0xbf7f
xorl %r14d, %r14d
leaq (%rbx,%rbx,8), %rax
shlq $0x4, %rax
movq %rax, 0x10(%rsp)
leaq 0xc(%rsp), %rdi
movq %r13, %rsi
callq 0xbbef
testb %al, %al
jne 0xbd47
cmpl $0x43, (%r13)
jne 0xbf7f
cmpl $0x43, (%r13)
movq (%r12), %rbp
jne 0xbe01
movq 0x8(%r12), %rax
subq %rbp, %rax
sarq $0x4, %rax
movabsq $-0x71c71c71c71c71c7, %rcx # imm = 0x8E38E38E38E38E39
imulq %rcx, %rax
cmpq %rax, %rbx
jae 0xc068
movl $0x16, 0x30(%rsp)
movb %r14b, 0x34(%rsp)
movq %r14, 0x38(%rsp)
movb $0x1, 0x40(%rsp)
fldz
fstpt 0x50(%rsp)
movl $0x0, 0x60(%rsp)
movq $-0x1, 0x70(%rsp)
leaq 0x88(%rsp), %rax
movq %rax, 0x78(%rsp)
movq %r14, 0x80(%rsp)
movb %r14b, 0x88(%rsp)
movq %r12, %rdi
leaq 0x30(%rsp), %rsi
callq 0xae2e
movq 0x10(%rsp), %rcx
leaq (%rcx,%rbp), %rdi
addq $0x70, %rdi
movq %rax, 0x20(%rsp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xbe77
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rdi)
jmp 0xbe81
movq 0x8(%r12), %rax
subq %rbp, %rax
sarq $0x4, %rax
movabsq $-0x71c71c71c71c71c7, %rcx # imm = 0x8E38E38E38E38E39
imulq %rcx, %rax
cmpq %rax, %rbx
jae 0xc04a
movq 0x10(%rsp), %rax
addq %rax, %rbp
addq $0x70, %rbp
leaq 0x70(%r13), %rax
movq %rax, (%r15)
movl 0xc(%rsp), %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0xae96
movq %rax, 0x30(%rsp)
movq 0x8(%rbp), %rsi
cmpq 0x10(%rbp), %rsi
je 0xbe65
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rbp)
jmp 0xbf6b
movq %rbp, %rdi
leaq 0x30(%rsp), %rdx
callq 0x11b40
jmp 0xbf6b
leaq 0x20(%rsp), %rdx
callq 0x11b40
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rbp
cmpq %rbp, %rdi
je 0xbea3
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x21d0
movq (%r12), %r13
movq 0x8(%r12), %rax
subq %r13, %rax
sarq $0x4, %rax
movabsq $-0x71c71c71c71c71c7, %rcx # imm = 0x8E38E38E38E38E39
imulq %rcx, %rax
cmpq %rax, %rbx
jae 0xc02c
movl $0x16, 0x30(%rsp)
movb %r14b, 0x34(%rsp)
movq %r14, 0x38(%rsp)
movb $0x1, 0x40(%rsp)
fldz
fstpt 0x50(%rsp)
movl $0x0, 0x60(%rsp)
movq $-0x1, 0x70(%rsp)
movq %rbp, 0x78(%rsp)
movq %r14, 0x80(%rsp)
movb %r14b, 0x88(%rsp)
movq %r12, %rdi
leaq 0x30(%rsp), %rsi
callq 0xae2e
movq 0x10(%rsp), %rcx
leaq (%rcx,%r13), %rdi
addq $0x70, %rdi
movq %rax, 0x20(%rsp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xbf43
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rdi)
jmp 0xbf4d
leaq 0x20(%rsp), %rdx
callq 0x11b40
movq 0x78(%rsp), %rdi
cmpq %rbp, %rdi
je 0xbf67
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x21d0
addq $0x70, (%r15)
movq (%r15), %r13
movq 0x18(%rsp), %rax
movq (%rax), %rbp
cmpq %rbp, %r13
jne 0xbd2b
cmpq %rbp, %r13
je 0xc09a
cmpl $0x21, (%r13)
movl 0x2c(%rsp), %eax
jne 0xc0b8
addq $0x70, %r13
movq %r13, (%r15)
testb %al, %al
je 0xc017
movq (%r12), %rax
movq 0x8(%r12), %rcx
subq %rax, %rcx
sarq $0x4, %rcx
movabsq $-0x71c71c71c71c71c7, %rdx # imm = 0x8E38E38E38E38E39
imulq %rdx, %rcx
cmpq %rcx, %rbx
jae 0xc0e4
leaq (%rbx,%rbx,8), %rcx
shlq $0x4, %rcx
leaq (%rax,%rcx), %r13
addq $0x70, %r13
movq %r12, %rdi
movq %r15, %rsi
movq 0x18(%rsp), %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0xb0e4
movq %rax, 0x30(%rsp)
movq 0x8(%r13), %rsi
cmpq 0x10(%r13), %rsi
je 0xc00a
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%r13)
jmp 0xc017
leaq 0x30(%rsp), %rdx
movq %r13, %rdi
callq 0x11b40
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x20e0
movq %rax, %r14
leaq 0x8677(%rip), %rsi      # 0x146b7
movq %rax, %rdi
callq 0x20b0
jmp 0xc084
movl $0x10, %edi
callq 0x20e0
movq %rax, %r14
leaq 0x8659(%rip), %rsi      # 0x146b7
movq %rax, %rdi
callq 0x20b0
jmp 0xc084
movl $0x10, %edi
callq 0x20e0
movq %rax, %r14
leaq 0x863b(%rip), %rsi      # 0x146b7
movq %rax, %rdi
callq 0x20b0
movq 0xdf6d(%rip), %rsi      # 0x19ff8
movq 0xdf1e(%rip), %rdx      # 0x19fb0
movq %r14, %rdi
callq 0x2330
movl $0x10, %edi
callq 0x20e0
movq %rax, %r14
leaq 0x80fa(%rip), %rsi      # 0x141a8
movq %rax, %rdi
callq 0x23a0
jmp 0xc0d4
movl $0x10, %edi
callq 0x20e0
movq %rax, %r14
leaq 0x80dc(%rip), %rsi      # 0x141a8
movq %rax, %rdi
callq 0x23a0
movq 0xdefd(%rip), %rsi      # 0x19fd8
movq 0xdede(%rip), %rdx      # 0x19fc0
jmp 0xc092
movl $0x10, %edi
callq 0x20e0
movq %rax, %r14
leaq 0x85bf(%rip), %rsi      # 0x146b7
movq %rax, %rdi
callq 0x20b0
jmp 0xc084
jmp 0xc11b
jmp 0xc11b
jmp 0xc11b
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
jne 0xc14c
jmp 0xc15c
jmp 0xc11b
jmp 0xc11b
movq %rax, %rbx
movq %r14, %rdi
callq 0x2160
jmp 0xc15c
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
jne 0xc14c
jmp 0xc15c
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %rbp, %rdi
je 0xc15c
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x21d0
movq %rbx, %rdi
callq 0x2360