// File: joncampbell123[P]haxcc/haxpp.cpp
// Function: parse_expr(expression&, __gnu_cxx::__normal_iterator<token*, std::vector<token, std::allocator<token>>>&, __gnu_cxx::__normal_iterator<token*, std::vector<token, std::allocator<token>>> const&, unsigned int)
expression::node::node_t parse_expr(expression &expr,token_string::iterator &ti,const token_string::iterator &tie,unsigned int min_prec) {
    if (ti == tie)
        throw invalid_argument("expected token for expr parse");

    expression::node::node_t headnode;

    /* (typecast) */
    headnode = parse_expr_typecast(expr,ti,tie);

    /* (expression) */
    if (headnode == expression::node::none)
        headnode = parse_expr_subexpr(expr,ti,tie);

    /* sizeof(type) */
    if (headnode == expression::node::none)
        headnode = parse_expr_sizeof(expr,ti,tie);

    /* expression
     * expression = ~expression */
    if (headnode == expression::node::none)
        headnode = parse_expr_rtl_unary(expr,ti,tie,min_prec,tokenlist_prec2_unary);

    /* number */
    if (headnode == expression::node::none)
        headnode = expr.newnode(*(ti++));

    /* expression
     * expression ++ -- () [] . -> expression */
    headnode = parse_expr_ltr_unary(expr,ti,tie,min_prec,tokenlist_prec1_unary,headnode);
    headnode = parse_expr_ltr(expr,ti,tie,min_prec,tokenlist_prec1_binary,headnode);

    /* expression
     * expression * / % + - << >> etc expression */
    headnode = parse_expr_ltr(expr,ti,tie,min_prec,tokenlist_precbinary3_12,headnode);

    /* expression
     * expression ? t-expression : f-expression */
    headnode = parse_expr_rtl_ternary(expr,ti,tie,min_prec,headnode);

    /* expression
     * expression = expression (also += -= *= etc) */
    headnode = parse_expr_rtl(expr,ti,tie,min_prec,tokenlist_prec14,headnode);

    /* expression
     * expression , expression */
    headnode = parse_expr_ltr(expr,ti,tie,min_prec,tokenlist_prec15,headnode);

    return headnode;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x16970
testb $0x1, %al
jne 0x10cfa
jmp 0x10d4d
movl $0x10, %edi
callq 0x3130
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x48(%rbp)
leaq 0x14822(%rip), %rsi     # 0x25537
callq 0x3530
jmp 0x10d1c
movq -0x48(%rbp), %rdi
movq 0x222b1(%rip), %rsi     # 0x32fd8
movq 0x22292(%rip), %rdx     # 0x32fc0
callq 0x34b0
movq -0x48(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x31f0
jmp 0x10ed1
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl $0x1, %ecx
callq 0x11890
movq %rax, -0x38(%rbp)
cmpq $-0x1, -0x38(%rbp)
jne 0x10d83
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x116b0
movq %rax, -0x38(%rbp)
cmpq $-0x1, -0x38(%rbp)
jne 0x10d9f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x11d90
movq %rax, -0x38(%rbp)
cmpq $-0x1, -0x38(%rbp)
jne 0x10dc5
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
leaq 0x13a84(%rip), %r8      # 0x24840
callq 0x10b30
movq %rax, -0x38(%rbp)
cmpq $-0x1, -0x38(%rbp)
jne 0x10dfc
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x165c0
movq %rax, -0x40(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x16600
movq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x109f0
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movq -0x38(%rbp), %r9
leaq 0x13a8a(%rip), %r8      # 0x248a0
callq 0x113b0
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movq -0x38(%rbp), %r9
leaq 0x13a87(%rip), %r8      # 0x248c0
callq 0x114d0
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movq -0x38(%rbp), %r9
leaq 0x13a84(%rip), %r8      # 0x248e0
callq 0x114d0
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movq -0x38(%rbp), %r8
callq 0x10ee0
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movq -0x38(%rbp), %r9
leaq 0x13ae5(%rip), %r8      # 0x24980
callq 0x111d0
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movq -0x38(%rbp), %r9
leaq 0x13b22(%rip), %r8      # 0x249e0
callq 0x114d0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x34e0
nopw (%rax,%rax)