// File: /workspace/github_cpp_makefile_star2_O1/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 0xb3ed
movq %rsi, %r15
movq %rdi, %r12
movabsq $-0x71c71c71c71c71c7, %rbp # imm = 0x8E38E38E38E38E39
cmpl $0x45, (%r14)
jne 0xb3ed
movq %r14, %rdi
xorl %esi, %esi
callq 0x291e
movl %eax, (%rsp)
cmpl 0x4(%rsp), %eax
ja 0xb3ed
movq %rbx, 0x10(%rsp)
leaq 0x70(%r14), %rax
movq %rax, (%r15)
movq %r12, %rdi
movq %r14, %rsi
movl $0x7e, %edx
callq 0xae96
movq %rax, %r13
movq (%r15), %rax
movq 0x8(%rsp), %rcx
cmpq (%rcx), %rax
je 0xb4ca
movq (%r12), %rax
movq 0x8(%r12), %rcx
subq %rax, %rcx
sarq $0x4, %rcx
imulq %rbp, %rcx
cmpq %rcx, %r13
jae 0xb462
movq %r15, %rbx
leaq (,%r13,8), %r14
addq %r13, %r14
shlq $0x4, %r14
leaq (%rax,%r14), %rdi
addq $0x70, %rdi
movl $0x3, %esi
callq 0xf1be
movq (%r12), %rax
movq 0x8(%r12), %rcx
subq %rax, %rcx
sarq $0x4, %rcx
imulq %rbp, %rcx
cmpq %rcx, %r13
jae 0xb49e
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 0xb0e4
movq (%r12), %rcx
movq 0x8(%r12), %rdx
subq %rcx, %rdx
sarq $0x4, %rdx
imulq %rbp, %rdx
cmpq %rdx, %r13
jae 0xb402
movq 0x70(%rcx,%r14), %rcx
movq %rax, 0x8(%rcx)
movq (%r15), %rax
cmpq (%rbx), %rax
je 0xb480
cmpl $0x46, (%rax)
jne 0xb423
addq $0x70, %rax
movq %rax, (%r15)
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movl (%rsp), %ecx
callq 0xb0e4
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 0xb444
movq %rbx, %rdx
movq 0x70(%rcx,%r14), %rcx
movq %rax, 0x10(%rcx)
movq (%r15), %r14
movq %r13, %rbx
cmpq (%rdx), %r14
jne 0xb285
jmp 0xb3f0
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 0x92a1(%rip), %rsi      # 0x146b7
movq %rax, %rdi
callq 0x20b0
jmp 0xb4ba
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x8d5c(%rip), %rsi      # 0x14193
movq %rax, %rdi
callq 0x23a0
jmp 0xb4e6
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x925f(%rip), %rsi      # 0x146b7
movq %rax, %rdi
callq 0x20b0
jmp 0xb4ba
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x9241(%rip), %rsi      # 0x146b7
movq %rax, %rdi
callq 0x20b0
jmp 0xb4ba
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x8cff(%rip), %rsi      # 0x14193
movq %rax, %rdi
callq 0x23a0
jmp 0xb4e6
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x9205(%rip), %rsi      # 0x146b7
movq %rax, %rdi
callq 0x20b0
movq 0xeb37(%rip), %rsi      # 0x19ff8
movq 0xeae8(%rip), %rdx      # 0x19fb0
jmp 0xb4f4
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0x8ca6(%rip), %rsi      # 0x14184
movq %rax, %rdi
callq 0x23a0
movq 0xeaeb(%rip), %rsi      # 0x19fd8
movq 0xeacc(%rip), %rdx      # 0x19fc0
movq %rbx, %rdi
callq 0x2330
jmp 0xb508
jmp 0xb508
jmp 0xb508
jmp 0xb508
jmp 0xb508
jmp 0xb508
movq %rax, %r14
movq %rbx, %rdi
callq 0x2160
movq %r14, %rdi
callq 0x2360