// File: /workspace/github_cpp_makefile_star2_O3/joncampbell123[P]haxcc/haxpp.cpp
// Function: parse_expr_rtl_ternary(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, unsigned long)
expression::node::node_t parse_expr_rtl_ternary(expression &expr,token_string::iterator &ti,const token_string::iterator &tie,unsigned int min_prec,expression::node::node_t headnode) {
    unsigned int prec;

    while (ti != tie && (*ti).tval == token::QUESTIONMARK && (prec=token::precedence(*ti,false)) <= min_prec) {
        const expression::node::node_t opnode = expr.newnode(*(ti++),token::TERNARY);

        if (ti != tie) {
            expr.getnode(opnode).children.resize(3);
            expr.getnode(opnode).children[0] = headnode;
            expr.getnode(opnode).children[1] = parse_expr(expr,ti,tie,prec);

            if (ti == tie)
                throw invalid_argument("Ternary ? expected :");
            if ((*ti).tval != token::COLON)
                throw invalid_argument("Ternary ? expected :");
            ti++;

            expr.getnode(opnode).children[2] = parse_expr(expr,ti,tie,prec);
            headnode = opnode;
        }
        else {
            throw invalid_argument("missing rvalue");
        }
    }

    return headnode;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %rbx
movl %ecx, 0x4(%rsp)
movq (%rsi), %r14
movq %rdx, 0x8(%rsp)
cmpq (%rdx), %r14
je 0xb385
movq %rsi, %r15
movq %rdi, %r12
movabsq $-0x71c71c71c71c71c7, %rbp # imm = 0x8E38E38E38E38E39
cmpl $0x45, (%r14)
jne 0xb385
movq %r14, %rdi
xorl %esi, %esi
callq 0x291e
movl %eax, (%rsp)
cmpl 0x4(%rsp), %eax
ja 0xb385
movq %rbx, 0x10(%rsp)
leaq 0x70(%r14), %rax
movq %rax, (%r15)
movq %r12, %rdi
movq %r14, %rsi
movl $0x7e, %edx
callq 0xae2e
movq %rax, %r13
movq (%r15), %rax
movq 0x8(%rsp), %rcx
cmpq (%rcx), %rax
je 0xb462
movq (%r12), %rax
movq 0x8(%r12), %rcx
subq %rax, %rcx
sarq $0x4, %rcx
imulq %rbp, %rcx
cmpq %rcx, %r13
jae 0xb3fa
movq %r15, %rbx
leaq (,%r13,8), %r14
addq %r13, %r14
shlq $0x4, %r14
leaq (%rax,%r14), %rdi
addq $0x70, %rdi
movl $0x3, %esi
callq 0xf148
movq (%r12), %rax
movq 0x8(%r12), %rcx
subq %rax, %rcx
sarq $0x4, %rcx
imulq %rbp, %rcx
cmpq %rcx, %r13
jae 0xb436
movq 0x70(%rax,%r14), %rax
movq 0x10(%rsp), %rcx
movq %rcx, (%rax)
movq %r12, %rdi
movq %rbx, %r15
movq %rbx, %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdx
movl (%rsp), %ecx
callq 0xb07c
movq (%r12), %rcx
movq 0x8(%r12), %rdx
subq %rcx, %rdx
sarq $0x4, %rdx
imulq %rbp, %rdx
cmpq %rdx, %r13
jae 0xb39a
movq 0x70(%rcx,%r14), %rcx
movq %rax, 0x8(%rcx)
movq (%r15), %rax
cmpq (%rbx), %rax
je 0xb418
cmpl $0x46, (%rax)
jne 0xb3bb
addq $0x70, %rax
movq %rax, (%r15)
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movl (%rsp), %ecx
callq 0xb07c
movq (%r12), %rcx
movq 0x8(%r12), %rdx
subq %rcx, %rdx
sarq $0x4, %rdx
movabsq $-0x71c71c71c71c71c7, %rsi # imm = 0x8E38E38E38E38E39
imulq %rsi, %rdx
cmpq %rdx, %r13
jae 0xb3dc
movq %rbx, %rdx
movq 0x70(%rcx,%r14), %rcx
movq %rax, 0x10(%rcx)
movq (%r15), %r14
movq %r13, %rbx
cmpq (%rdx), %r14
jne 0xb21d
jmp 0xb388
movq %rbx, %r13
movq %r13, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x9399(%rip), %rsi      # 0x14747
movq %rax, %rdi
callq 0x20b0
jmp 0xb452
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x8e54(%rip), %rsi      # 0x14223
movq %rax, %rdi
callq 0x23a0
jmp 0xb47e
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x9357(%rip), %rsi      # 0x14747
movq %rax, %rdi
callq 0x20b0
jmp 0xb452
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x9339(%rip), %rsi      # 0x14747
movq %rax, %rdi
callq 0x20b0
jmp 0xb452
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x8df7(%rip), %rsi      # 0x14223
movq %rax, %rdi
callq 0x23a0
jmp 0xb47e
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x92fd(%rip), %rsi      # 0x14747
movq %rax, %rdi
callq 0x20b0
movq 0xeb9f(%rip), %rsi      # 0x19ff8
movq 0xeb50(%rip), %rdx      # 0x19fb0
jmp 0xb48c
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x8d9e(%rip), %rsi      # 0x14214
movq %rax, %rdi
callq 0x23a0
movq 0xeb53(%rip), %rsi      # 0x19fd8
movq 0xeb34(%rip), %rdx      # 0x19fc0
movq %rbx, %rdi
callq 0x2330
jmp 0xb4a0
jmp 0xb4a0
jmp 0xb4a0
jmp 0xb4a0
jmp 0xb4a0
jmp 0xb4a0
movq %rax, %r14
movq %rbx, %rdi
callq 0x2160
movq %r14, %rdi
callq 0x2360