// File: /workspace/github_cpp_makefile_star2_O1/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
movb %sil, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movq %rdi, (%rsp)
movq 0x8(%rdi), %rbx
leaq -0x18(%rbx), %r13
movq (%rcx), %rdi
callq 0x3686
movq %rax, (%r15)
movb (%rax), %cl
testb %cl, %cl
je 0x49bb
movq %r14, %rdx
movb (%rdx), %sil
cmpb %cl, %sil
je 0x49b6
incq %rdx
testb %sil, %sil
jne 0x49a6
testb %sil, %sil
je 0x49da
movq -0x10(%rbx), %rsi
cmpq -0x18(%rbx), %rsi
je 0x4a33
cmpq -0x8(%rbx), %rsi
je 0x4a26
movups 0x8(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, -0x10(%rbx)
jmp 0x4a33
movq -0x18(%rbx), %rbp
movq -0x10(%rbx), %r12
cmpb $0x1, 0x8(%rsp)
jne 0x4a52
movq %rbp, 0x28(%rsp)
leaq 0x18(%rsp), %rbp
movq %rbp, %rdi
movq %rax, %rsi
callq 0x3700
movl 0xc(%rbp), %ebp
cmpl $0x1, %ebp
jne 0x4a6c
movq -0x10(%rbx), %rsi
cmpq -0x8(%rbx), %rsi
je 0x4af7
movups 0x8(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, -0x10(%rbx)
jmp 0x4b04
leaq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x686c
cmpb $0x0, 0x8(%rsp)
je 0x513a
movq 0x10(%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq -0x8(%rbx), %r12
je 0x4aa1
movups 0x8(%rsp), %xmm0
movups %xmm0, (%r12)
addq $0x10, -0x10(%rbx)
jmp 0x4b4f
movq (%r15), %rdi
movzbl (%rdi), %eax
cmpl $0x5b, %eax
je 0x4ab6
cmpl $0x28, %eax
jne 0x5197
cmpb $0x0, 0x8(%rsp)
je 0x513a
movq 0x10(%rsp), %rsi
movq (%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rdx
callq 0x6484
jmp 0x4ad5
leaq 0x8(%rsp), %rdx
movq %r13, %rdi
movq %r12, %rsi
callq 0x686c
jmp 0x4b4f
cmpb $0x0, 0x8(%rsp)
je 0x513a
movq 0x10(%rsp), %rsi
movq (%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rdx
callq 0x65ee
movb $0x1, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
movl $0x1, %esi
movq %rax, %rdx
movq %r15, %rcx
movq %r14, %r8
callq 0x4968
jmp 0x4b41
leaq 0x8(%rsp), %rdx
movq %r13, %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 0x4b34
movups 0x38(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, -0x10(%rbx)
jmp 0x4b41
leaq 0x38(%rsp), %rdx
movq %r13, %rdi
callq 0x69ac
cmpl $0x1, %ebp
movq 0x28(%rsp), %rbp
jne 0x4a43
movq (%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x4490
cmpq %rbp, %r12
jne 0x4a43
movq 0x8(%rbx), %rbp
leaq 0x8903(%rip), %rax      # 0xd478
movq (%rax), %r14
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
cmpq %rax, %r14
je 0x50ec
movq %rbx, %r15
movq -0x18(%rbp), %rax
cmpb $0x0, 0x38(%r14)
je 0x4ed7
movq -0x10(%rbp), %rbx
subq %rax, %rbx
shrq $0x4, %rbx
movl %ebx, %r13d
decl %r13d
js 0x50dd
movl %r13d, %r12d
movq -0x18(%rbp), %rax
shlq $0x4, %r12
cmpb $0x0, (%rax,%r12)
jne 0x4ecf
movq -0x18(%rbp), %rax
cmpb $0x1, (%rax,%r12)
je 0x511b
addq %r12, %rax
movq 0x8(%rax), %rax
movq %rax, 0x18(%rsp)
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
callq 0x4370
testq %rax, %rax
je 0x4ecf
movl 0x3c(%r14), %eax
testl %eax, %eax
setne %cl
testl %r13d, %r13d
sete %dl
orb %cl, %dl
jne 0x4cc8
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rdx
subq %rcx, %rdx
shrq $0x4, %rdx
decl %edx
cmpl %edx, %r13d
jge 0x4cc8
leal -0x2(%rbx), %eax
shlq $0x4, %rax
cmpb $0x0, (%rcx,%rax)
je 0x513a
movl %ebx, %edi
shlq $0x4, %rdi
cmpb $0x0, (%rcx,%rdi)
je 0x513a
addq %rcx, %rax
addq %rcx, %rdi
movq 0x18(%rsp), %rdx
movq 0x8(%rax), %rsi
movq 0x8(%rdi), %rcx
movq %r15, %rdi
callq 0x6810
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 0x4c99
addq %r12, %rdi
addq $0x10, %rdi
subq %rsi, %rdx
callq 0x2230
movq -0x10(%rbp), %rdx
addq $-0x10, %rdx
movq %rdx, -0x10(%rbp)
addq -0x18(%rbp), %r12
cmpq %rdx, %r12
je 0x4cbe
leaq -0x10(%r12), %rdi
subq %r12, %rdx
movq %r12, %rsi
callq 0x2230
addq $-0x10, -0x10(%rbp)
jmp 0x4ecf
cmpl $0x3, %eax
je 0x4d93
cmpl $0x1, %eax
jne 0x4ecf
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rdx
subq %rcx, %rdx
shrq $0x4, %rdx
decl %edx
cmpl %edx, %r13d
jge 0x4d8a
testl %r13d, %r13d
je 0x4d0a
leal -0x2(%rbx), %eax
shlq $0x4, %rax
cmpb $0x0, (%rcx,%rax)
jne 0x4ecf
movl %ebx, %eax
shlq $0x4, %rax
cmpb $0x0, (%rcx,%rax)
je 0x513a
addq %rax, %rcx
movq 0x18(%rsp), %rbx
movq 0x8(%rcx), %r15
movq (%rsp), %rax
movq 0x28(%rax), %rdi
movl $0x20, %esi
callq 0x3cb4
movq $0x0, (%rax)
movl $0x6, 0x8(%rax)
movq %rbx, 0x10(%rax)
movq %r15, 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 0x4d80
addq %r12, %rdi
addq $0x10, %rdi
subq %rsi, %rdx
callq 0x2230
addq $-0x10, -0x10(%rbp)
jmp 0x4ecb
cmpl $0x3, %eax
jne 0x4ecf
movq 0x18(%rsp), %rax
leaq 0x8651(%rip), %rcx      # 0xd3f0
cmpq (%rcx), %rax
jne 0x4ecf
cmpl $0x3, %r13d
jl 0x5159
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rax, %rcx
shrq $0x4, %rcx
decl %ecx
cmpl %ecx, %r13d
jge 0x5159
leal -0x3(%rbx), %ecx
shlq $0x4, %rcx
cmpb $0x1, (%rax,%rcx)
je 0x511b
addq %rax, %rcx
movq 0x8(%rcx), %rcx
leaq 0x85fd(%rip), %rdx      # 0xd3e8
cmpq (%rdx), %rcx
jne 0x4ecf
leal -0x4(%rbx), %r13d
shlq $0x4, %r13
cmpb $0x0, (%rax,%r13)
je 0x513a
leal -0x2(%rbx), %ecx
shlq $0x4, %rcx
cmpb $0x0, (%rax,%rcx)
je 0x513a
movl %ebx, %edx
shlq $0x4, %rdx
cmpb $0x0, (%rax,%rdx)
je 0x513a
leaq (%rax,%r13), %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 0x3cb4
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,%r13)
movq %rax, 0x8(%rcx,%r13)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdx
leaq (%rax,%r12), %r13
addq $-0x20, %r13
addq %rax, %r12
addq $0x20, %r12
subq %r12, %rdx
je 0x4ea9
movq %r13, %rdi
movq %r12, %rsi
callq 0x2230
movq -0x10(%rbp), %rax
movq %rax, %rcx
subq %r12, %rcx
addq %rcx, %r13
cmpq %r13, %rax
je 0x4ebf
movq %r13, -0x10(%rbp)
movq -0x10(%rbp), %r13
subq -0x18(%rbp), %r13
shrq $0x4, %r13
movq (%rsp), %r15
movl %r13d, %ebx
jmp 0x4baa
movq -0x10(%rbp), %rcx
subq %rax, %rcx
shrq $0x4, %rcx
testl %ecx, %ecx
jle 0x50dd
xorl %ebx, %ebx
movslq %ebx, %r12
shlq $0x4, %r12
cmpb $0x0, (%rax,%r12)
jne 0x502e
movq -0x18(%rbp), %rax
cmpb $0x1, (%rax,%r12)
je 0x511b
addq %r12, %rax
movq 0x8(%rax), %rax
movq %rax, 0x18(%rsp)
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
callq 0x4370
testq %rax, %rax
je 0x5028
movl 0x3c(%r14), %ecx
testl %ecx, %ecx
setne %al
testl %ebx, %ebx
setle %dl
orb %al, %dl
jne 0x4ffd
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdx
subq %rax, %rdx
shrq $0x4, %rdx
decl %edx
cmpl %edx, %ebx
jge 0x4ffd
leal -0x1(%rbx), %r13d
movq %r13, %rcx
shlq $0x4, %rcx
cmpb $0x0, (%rax,%rcx)
je 0x513a
movl %ebx, %edi
shlq $0x4, %rdi
cmpb $0x0, 0x10(%rax,%rdi)
je 0x513a
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), %rdi
movq -0x10(%rbp), %rdx
leaq (%rdi,%r12), %rsi
addq $0x20, %rsi
cmpq %rdx, %rsi
je 0x4fd1
addq %r12, %rdi
addq $0x10, %rdi
subq %rsi, %rdx
callq 0x2230
movq -0x10(%rbp), %rdx
addq $-0x10, %rdx
movq %rdx, -0x10(%rbp)
addq -0x18(%rbp), %r12
cmpq %rdx, %r12
je 0x4ff6
leaq -0x10(%r12), %rdi
subq %r12, %rdx
movq %r12, %rsi
callq 0x2230
addq $-0x10, -0x10(%rbp)
jmp 0x502b
cmpl $0x1, %ecx
jne 0x5028
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rax, %rcx
shrq $0x4, %rcx
decl %ecx
cmpl %ecx, %ebx
jge 0x5028
testl %ebx, %ebx
jle 0x504c
movl %ebx, %ecx
shlq $0x4, %rcx
cmpb $0x0, -0x10(%rax,%rcx)
je 0x504c
movl %ebx, %r13d
movl %r13d, %ebx
incl %ebx
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rax, %rcx
shrq $0x4, %rcx
cmpl %ecx, %ebx
jl 0x4eec
jmp 0x50dd
cmpb $0x0, 0x10(%rax,%r12)
je 0x513a
addq %r12, %rax
movq 0x18(%rsp), %r15
movq 0x18(%rax), %r13
movq (%rsp), %rax
movq 0x28(%rax), %rdi
movl $0x20, %esi
callq 0x3cb4
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 0x50be
addq %r12, %rdi
addq $0x10, %rdi
subq %rsi, %rdx
callq 0x2230
addq $-0x10, -0x10(%rbp)
cmpl $0x3, %ebx
movl $0x2, %eax
cmovll %eax, %ebx
addl $-0x2, %ebx
movl %ebx, %r13d
movq (%rsp), %r15
jmp 0x502b
addq $0x40, %r14
cmpq 0x28(%rsp), %r14
jne 0x4b8d
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rdx
movq %rdx, %rax
subq %rcx, %rax
cmpq $0x10, %rax
jne 0x5178
cmpb $0x0, (%rcx)
je 0x513a
movq 0x8(%rcx), %rax
cmpq %rcx, %rdx
je 0x4a43
movq %rcx, -0x10(%rbp)
jmp 0x4a43
leaq 0x3c36(%rip), %rdi      # 0x8d58
leaq 0x30ce(%rip), %rsi      # 0x81f7
leaq 0x3c30(%rip), %rcx      # 0x8d60
movl $0x296, %edx            # imm = 0x296
callq 0x2100
leaq 0x3c18(%rip), %rdi      # 0x8d59
leaq 0x30af(%rip), %rsi      # 0x81f7
leaq 0x3b87(%rip), %rcx      # 0x8cd6
movl $0x292, %edx            # imm = 0x292
callq 0x2100
leaq 0x3b42(%rip), %rdi      # 0x8ca2
leaq 0x3090(%rip), %rsi      # 0x81f7
leaq 0x3a95(%rip), %rcx      # 0x8c03
movl $0x2f0, %edx            # imm = 0x2F0
callq 0x2100
leaq 0x3b45(%rip), %rdi      # 0x8cc4
leaq 0x3071(%rip), %rsi      # 0x81f7
leaq 0x3a76(%rip), %rcx      # 0x8c03
movl $0x30b, %edx            # imm = 0x30B
callq 0x2100
callq 0x239f