// File: /workspace/github_cpp_makefile_star2_O3/lukewagner[P]asmjs2wasm/src/cashew/parser.h
// Function: cashew::Parser<asmjs_ast::Node*, Builder>::parseExpression(cashew::Parser<asmjs_ast::Node*, Builder>::ExpressionElement, char*&, char const*)
NodeRef parseExpression(ExpressionElement initial, char*&src, const char* seps) {
    //dump("parseExpression", src);
    ExpressionParts& parts = expressionPartsStack.back();
    src = skipSpace(src);
    if (*src == 0 || hasChar(seps, *src)) {
      if (parts.size() > 0) {
        parts.push_back(initial); // cherry on top of the cake
      }
      return initial.getNode();
    }
    bool top = parts.size() == 0;
    if (initial.isNode) {
      Frag next(src);
      if (next.type == OPERATOR) {
        parts.push_back(initial);
        src += next.size;
        parts.push_back(next.str);
      } else {
        if (*src == '(') {
          initial = parseCall(initial.getNode(), src);
        } else if (*src == '[') {
          initial = parseIndexing(initial.getNode(), src);
        } else {
          dump("bad parseExpression state", src);
          assert(0);
        }
        return parseExpression(initial, src, seps);
      }
    } else {
      parts.push_back(initial);
    }
    NodeRef last = parseElement(src, seps);
    if (!top) return last;
    {
      ExpressionParts& parts = expressionPartsStack.back(); // |parts| may have been invalidated by that call
      // we are the toplevel. sort it all out
      // collapse right to left, highest priority first
      //dumpParts(parts, 0);
      for (auto& ops : operatorClasses) {
        if (ops.rtl) {
          // right to left
          for (int i = parts.size()-1; i >= 0; i--) {
            if (parts[i].isNode) continue;
            IString op = parts[i].getOp();
            if (!ops.ops.has(op)) continue;
            if (ops.type == OperatorClass::Binary && i > 0 && i < (int)parts.size()-1) {
              parts[i] = makeBinary(parts[i-1].getNode(), op, parts[i+1].getNode());
              parts.erase(parts.begin() + i + 1);
              parts.erase(parts.begin() + i - 1);
            } else if (ops.type == OperatorClass::Prefix && i < (int)parts.size()-1) {
              if (i > 0 && parts[i-1].isNode) continue; // cannot apply prefix operator if it would join two nodes
              parts[i] = builder.makePrefix(op, parts[i+1].getNode());
              parts.erase(parts.begin() + i + 1);
            } else if (ops.type == OperatorClass::Tertiary) {
              // we must be at  X ? Y : Z
              //                      ^
              //dumpParts(parts, i);
              if (op != COLON) continue;
              assert(i < (int)parts.size()-1 && i >= 3);
              if (parts[i-2].getOp() != QUESTION) continue; // e.g. x ? y ? 1 : 0 : 2
              parts[i-3] = builder.makeConditional(parts[i-3].getNode(), parts[i-1].getNode(), parts[i+1].getNode());
              parts.erase(parts.begin() + i - 2, parts.begin() + i + 2);
              i = parts.size(); // basically a reset, due to things like x ? y ? 1 : 0 : 2
            } // TODO: postfix
          }
        } else {
          // left to right
          for (int i = 0; i < (int)parts.size(); i++) {
            if (parts[i].isNode) continue;
            IString op = parts[i].getOp();
            if (!ops.ops.has(op)) continue;
            if (ops.type == OperatorClass::Binary && i > 0 && i < (int)parts.size()-1) {
              parts[i] = makeBinary(parts[i-1].getNode(), op, parts[i+1].getNode());
              parts.erase(parts.begin() + i + 1);
              parts.erase(parts.begin() + i - 1);
              i--;
            } else if (ops.type == OperatorClass::Prefix && i < (int)parts.size()-1) {
              if (i > 0 && parts[i-1].isNode) continue; // cannot apply prefix operator if it would join two nodes
              parts[i] = builder.makePrefix(op, parts[i+1].getNode());
              parts.erase(parts.begin() + i + 1);
              i = std::max(i-2, 0); // allow a previous prefix operator to cascade
            } // TODO: tertiary, postfix
          }
        }
      }
      assert(parts.size() == 1);
      NodeRef ret = parts[0].getNode();
      parts.clear();
      return ret;
    }
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, %r14
movq %rcx, %r15
movl %esi, %ebp
movb %bpl, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movq %rdi, (%rsp)
movq 0x8(%rdi), %rbx
leaq -0x18(%rbx), %r12
movq (%rcx), %rdi
callq 0x3692
movq %rax, (%r15)
movb (%rax), %cl
testb %cl, %cl
je 0x49a1
movq %r14, %rdx
movb (%rdx), %sil
cmpb %cl, %sil
je 0x499c
incq %rdx
testb %sil, %sil
jne 0x498c
testb %sil, %sil
je 0x49c0
movq -0x10(%rbx), %rsi
cmpq -0x18(%rbx), %rsi
je 0x4a16
cmpq -0x8(%rbx), %rsi
je 0x4a09
movups 0x8(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, -0x10(%rbx)
jmp 0x4a16
movq -0x18(%rbx), %rcx
movq %rcx, 0x28(%rsp)
movq -0x10(%rbx), %r13
testb $0x1, %bpl
je 0x4a35
leaq 0x18(%rsp), %rbp
movq %rbp, %rdi
movq %rax, %rsi
callq 0x3704
cmpl $0x1, 0xc(%rbp)
jne 0x4a4a
movq -0x10(%rbx), %rsi
cmpq -0x8(%rbx), %rsi
je 0x4ad8
movups 0x8(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, -0x10(%rbx)
jmp 0x4ae5
leaq 0x8(%rsp), %rdx
movq %r12, %rdi
callq 0x686c
cmpb $0x0, 0x8(%rsp)
je 0x5102
movq 0x10(%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq -0x8(%rbx), %r13
je 0x4a7f
movups 0x8(%rsp), %xmm0
movups %xmm0, (%r13)
jmp 0x4b12
movq (%r15), %rdi
movzbl (%rdi), %eax
cmpl $0x5b, %eax
je 0x4a94
cmpl $0x28, %eax
jne 0x517e
cmpb $0x0, 0x8(%rsp)
je 0x5102
movq 0x10(%rsp), %rsi
movq (%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rdx
callq 0x647a
jmp 0x4ab3
leaq 0x8(%rsp), %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x686c
jmp 0x4b17
cmpb $0x0, 0x8(%rsp)
je 0x5102
movq 0x10(%rsp), %rsi
movq (%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rdx
callq 0x65ea
movb $0x1, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
movl $0x1, %esi
movq %rax, %rdx
movq %r15, %rcx
movq %r14, %r8
callq 0x494c
jmp 0x4a26
leaq 0x8(%rsp), %rdx
movq %r12, %rdi
callq 0x686c
movslq 0x20(%rsp), %rax
addq %rax, (%r15)
movq 0x18(%rsp), %rax
movb $0x0, 0x38(%rsp)
movq %rax, 0x40(%rsp)
movq -0x10(%rbx), %rsi
cmpq -0x8(%rbx), %rsi
je 0x50f0
movups 0x38(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, -0x10(%rbx)
movq (%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x4484
cmpq 0x28(%rsp), %r13
jne 0x4a26
movq 0x8(%rbx), %rbp
leaq 0x8939(%rip), %rax      # 0xd478
movq (%rax), %r14
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
cmpq %rax, %r14
je 0x50bd
movq %rbx, %r15
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, %rbx
subq %rax, %rbx
shrq $0x4, %rbx
cmpb $0x0, 0x38(%r14)
je 0x4eac
movl %ebx, %r12d
decl %r12d
js 0x50ae
movl %r12d, %r13d
movq -0x18(%rbp), %rax
shlq $0x4, %r13
cmpb $0x0, (%rax,%r13)
jne 0x4ea4
addq %r13, %rax
movq 0x8(%rax), %rax
movq %rax, 0x18(%rsp)
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
callq 0x435c
testq %rax, %rax
je 0x4ea4
movl 0x3c(%r14), %eax
testl %eax, %eax
setne %cl
testl %r12d, %r12d
sete %dl
orb %cl, %dl
jne 0x4c93
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rax, %rcx
shrq $0x4, %rcx
decl %ecx
cmpl %ecx, %r12d
jge 0x4ea4
movslq %ebx, %rcx
shlq $0x4, %rcx
cmpb $0x0, -0x20(%rax,%rcx)
je 0x5102
movl %ebx, %edi
shlq $0x4, %rdi
cmpb $0x0, (%rax,%rdi)
je 0x5102
addq %rax, %rcx
addq %rax, %rdi
movq 0x18(%rsp), %rdx
movq -0x18(%rcx), %rsi
movq 0x8(%rdi), %rcx
movq %r15, %rdi
callq 0x6810
movq -0x18(%rbp), %rcx
movb $0x1, (%rcx,%r13)
movq %rax, 0x8(%rcx,%r13)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdx
leaq (%rax,%r13), %rsi
addq $0x20, %rsi
cmpq %rdx, %rsi
je 0x4c63
addq %r13, %rax
addq $0x10, %rax
subq %rsi, %rdx
movq %rax, %rdi
callq 0x2230
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdx
addq $-0x10, %rdx
movq %rdx, -0x10(%rbp)
addq %r13, %rax
cmpq %rdx, %rax
je 0x4c86
leaq -0x10(%rax), %rdi
subq %rax, %rdx
movq %rax, %rsi
callq 0x2230
movq -0x10(%rbp), %rdx
addq $-0x10, %rdx
movq %rdx, -0x10(%rbp)
jmp 0x4ea4
cmpl $0x3, %eax
je 0x4d61
cmpl $0x1, %eax
jne 0x4ea4
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rax, %rcx
shrq $0x4, %rcx
decl %ecx
cmpl %ecx, %r12d
jge 0x4ea4
testl %r12d, %r12d
je 0x4cd6
movslq %ebx, %rcx
shlq $0x4, %rcx
cmpb $0x0, -0x20(%rax,%rcx)
jne 0x4ea4
movl %ebx, %ecx
shlq $0x4, %rcx
cmpb $0x0, (%rax,%rcx)
je 0x5102
addq %rcx, %rax
movq 0x18(%rsp), %rbx
movq 0x8(%rax), %r15
movq (%rsp), %rax
movq 0x28(%rax), %rdi
movl $0x20, %esi
callq 0x3ca4
movq $0x0, (%rax)
movl $0x6, 0x8(%rax)
movq %rbx, 0x10(%rax)
movq %r15, 0x18(%rax)
movq -0x18(%rbp), %rcx
movb $0x1, (%rcx,%r13)
movq %rax, 0x8(%rcx,%r13)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq (%rdi,%r13), %rsi
addq $0x20, %rsi
cmpq %rdx, %rsi
je 0x4d50
addq %r13, %rdi
addq $0x10, %rdi
subq %rsi, %rdx
callq 0x2230
movq -0x10(%rbp), %rdx
addq $-0x10, %rdx
movq %rdx, -0x10(%rbp)
movq (%rsp), %r15
jmp 0x4ea4
movq 0x18(%rsp), %rax
leaq 0x8683(%rip), %rcx      # 0xd3f0
cmpq (%rcx), %rax
jne 0x4ea4
cmpl $0x3, %r12d
jb 0x5121
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rax, %rcx
shrq $0x4, %rcx
decl %ecx
cmpl %ecx, %r12d
jge 0x5121
leal -0x3(%rbx), %ecx
shlq $0x4, %rcx
cmpb $0x1, (%rax,%rcx)
je 0x5140
addq %rax, %rcx
movq 0x8(%rcx), %rcx
leaq 0x862f(%rip), %rdx      # 0xd3e8
cmpq (%rdx), %rcx
jne 0x4ea4
leal -0x4(%rbx), %r12d
shlq $0x4, %r12
cmpb $0x0, (%rax,%r12)
je 0x5102
leal -0x2(%rbx), %ecx
shlq $0x4, %rcx
cmpb $0x0, (%rax,%rcx)
je 0x5102
movl %ebx, %edx
shlq $0x4, %rdx
cmpb $0x0, (%rax,%rdx)
je 0x5102
leaq (%rax,%r12), %rsi
movq 0x8(%rsi), %rsi
movq %rsi, 0x30(%rsp)
addq %rax, %rcx
addq %rax, %rdx
movq 0x8(%rcx), %r15
movq 0x8(%rdx), %rbx
movq (%rsp), %rax
movq 0x28(%rax), %rdi
movl $0x28, %esi
callq 0x3ca4
movq $0x0, (%rax)
movl $0x8, 0x8(%rax)
movq 0x30(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq %r15, 0x18(%rax)
movq %rbx, 0x20(%rax)
movq -0x18(%rbp), %rcx
movb $0x1, (%rcx,%r12)
movq %rax, 0x8(%rcx,%r12)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdx
leaq (%rax,%r13), %rbx
addq $-0x20, %rbx
addq %rax, %r13
addq $0x20, %r13
subq %r13, %rdx
je 0x4e80
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2230
movq -0x10(%rbp), %r12
movq %r12, %rax
jmp 0x4e86
movq %r13, %r12
movq %r13, %rax
subq %r13, %rax
addq %rax, %rbx
cmpq %rbx, %r12
movq (%rsp), %r15
je 0x4e9c
movq %rbx, -0x10(%rbp)
movq %rbx, %r12
subq -0x18(%rbp), %r12
shrq $0x4, %r12
movl %r12d, %ebx
jmp 0x4b77
testl %ebx, %ebx
jle 0x50ae
xorl %ebx, %ebx
movslq %ebx, %r12
shlq $0x4, %r12
cmpb $0x0, (%rax,%r12)
jne 0x4ffd
addq %r12, %rax
movq 0x8(%rax), %rax
movq %rax, 0x18(%rsp)
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
callq 0x435c
testq %rax, %rax
je 0x4fef
movl 0x3c(%r14), %eax
testl %eax, %eax
setne %cl
testl %ebx, %ebx
setle %dl
orb %cl, %dl
jne 0x4fc4
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rax, %rcx
shrq $0x4, %rcx
decl %ecx
cmpl %ecx, %ebx
jge 0x4fef
leal -0x1(%rbx), %r13d
movq %r13, %rcx
shlq $0x4, %rcx
cmpb $0x0, (%rax,%rcx)
je 0x5102
movl %ebx, %edi
shlq $0x4, %rdi
cmpb $0x0, 0x10(%rax,%rdi)
je 0x5102
addq %rax, %rcx
addq %rax, %rdi
movq 0x18(%rsp), %rdx
movq 0x8(%rcx), %rsi
movq 0x18(%rdi), %rcx
movq %r15, %rdi
callq 0x6810
movq -0x18(%rbp), %rcx
movb $0x1, (%rcx,%r12)
movq %rax, 0x8(%rcx,%r12)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdx
leaq (%rax,%r12), %rsi
addq $0x20, %rsi
cmpq %rdx, %rsi
je 0x4f97
addq %r12, %rax
addq $0x10, %rax
subq %rsi, %rdx
movq %rax, %rdi
callq 0x2230
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdx
addq $-0x10, %rdx
movq %rdx, -0x10(%rbp)
addq %r12, %rax
cmpq %rdx, %rax
je 0x4fba
leaq -0x10(%rax), %rdi
subq %rax, %rdx
movq %rax, %rsi
callq 0x2230
movq -0x10(%rbp), %rdx
addq $-0x10, %rdx
movq %rdx, -0x10(%rbp)
jmp 0x4ff2
cmpl $0x1, %eax
jne 0x4fef
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rax, %rcx
shrq $0x4, %rcx
decl %ecx
cmpl %ecx, %ebx
jge 0x4fef
testl %ebx, %ebx
jle 0x5016
movl %ebx, %ecx
shlq $0x4, %rcx
cmpb $0x0, -0x10(%rax,%rcx)
je 0x5016
movl %ebx, %r13d
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movl %r13d, %ebx
incl %ebx
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x4, %rdx
cmpl %edx, %ebx
jl 0x4eb6
jmp 0x50ae
cmpb $0x0, 0x10(%rax,%r12)
je 0x5102
addq %r12, %rax
movq 0x18(%rsp), %r15
movq 0x18(%rax), %r13
movq (%rsp), %rax
movq 0x28(%rax), %rdi
movl $0x20, %esi
callq 0x3ca4
movq $0x0, (%rax)
movl $0x6, 0x8(%rax)
movq %r15, 0x10(%rax)
movq %r13, 0x18(%rax)
movq -0x18(%rbp), %rcx
movb $0x1, (%rcx,%r12)
movq %rax, 0x8(%rcx,%r12)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq (%rdi,%r12), %rsi
addq $0x20, %rsi
cmpq %rdx, %rsi
je 0x508c
addq %r12, %rdi
addq $0x10, %rdi
subq %rsi, %rdx
callq 0x2230
movq -0x10(%rbp), %rdx
addq $-0x10, %rdx
movq %rdx, -0x10(%rbp)
cmpl $0x3, %ebx
movl $0x2, %eax
cmovll %eax, %ebx
addl $-0x2, %ebx
movl %ebx, %r13d
movq (%rsp), %r15
jmp 0x4ff2
addq $0x40, %r14
cmpq 0x28(%rsp), %r14
jne 0x4b57
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rdx
movq %rdx, %rax
subq %rcx, %rax
cmpq $0x10, %rax
jne 0x515f
cmpb $0x0, (%rcx)
je 0x5102
movq 0x8(%rcx), %rax
cmpq %rcx, %rdx
je 0x4a26
movq %rcx, -0x10(%rbp)
jmp 0x4a26
leaq 0x38(%rsp), %rdx
movq %r12, %rdi
callq 0x69ac
jmp 0x4b17
leaq 0x3c50(%rip), %rdi      # 0x8d59
leaq 0x30e7(%rip), %rsi      # 0x81f7
leaq 0x3bbf(%rip), %rcx      # 0x8cd6
movl $0x292, %edx            # imm = 0x292
callq 0x2100
leaq 0x3b7a(%rip), %rdi      # 0x8ca2
leaq 0x30c8(%rip), %rsi      # 0x81f7
leaq 0x3acd(%rip), %rcx      # 0x8c03
movl $0x2f0, %edx            # imm = 0x2F0
callq 0x2100
leaq 0x3c11(%rip), %rdi      # 0x8d58
leaq 0x30a9(%rip), %rsi      # 0x81f7
leaq 0x3c0b(%rip), %rcx      # 0x8d60
movl $0x296, %edx            # imm = 0x296
callq 0x2100
leaq 0x3b5e(%rip), %rdi      # 0x8cc4
leaq 0x308a(%rip), %rsi      # 0x81f7
leaq 0x3a8f(%rip), %rcx      # 0x8c03
movl $0x30b, %edx            # imm = 0x30B
callq 0x2100
callq 0x239f
nop