// File: /workspace/github_cpp_makefile_star2_O1/lukewagner[P]asmjs2wasm/src/cashew/parser.h
// Function: cashew::Parser<asmjs_ast::Node*, Builder>::parseSwitch(cashew::Parser<asmjs_ast::Node*, Builder>::Frag&, char*&, char const*)
NodeRef parseSwitch(Frag& frag, char*& src, const char* seps) {
    NodeRef ret = builder.makeSwitch(parseParenned(src));
    src = skipSpace(src);
    assert(*src == '{');
    src++;
    while (1) {
      // find all cases and possibly a default
      src = skipSpace(src);
      if (*src == '}') break;
      Frag next(src);
      if (next.type == KEYWORD) {
        if (next.str == CASE) {
          src += next.size;
          src = skipSpace(src);
          NodeRef arg;
          Frag value(src);
          if (value.isNumber()) {
            arg = parseFrag(value);
            src += value.size;
          } else {
            assert(value.type == OPERATOR);
            assert(value.str == MINUS);
            src += value.size;
            src = skipSpace(src);
            Frag value2(src);
            assert(value2.isNumber());
            arg = builder.makePrefix(MINUS, parseFrag(value2));
            src += value2.size;
          }
          builder.appendCaseToSwitch(ret, arg);
          src = skipSpace(src);
          assert(*src == ':');
          src++;
          continue;
        } else if (next.str == DEFAULT) {
          src += next.size;
          builder.appendDefaultToSwitch(ret);
          src = skipSpace(src);
          assert(*src == ':');
          src++;
          continue;
        }
        // otherwise, may be some keyword that happens to start a block (e.g. case 1: _return_ 5)
      }
      // not case X: or default: or }, so must be some code
      src = skipSpace(src);
      bool explicitBlock = *src == '{';
      builder.appendCodeToSwitch(ret, parseMaybeBracketedBlock(src, ";}", CASE, DEFAULT), explicitBlock);
    }
    src = skipSpace(src);
    assert(*src == '}');
    src++;
    return ret;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %rbx
movq %rdi, %r15
movq %rdx, %rsi
callq 0x61e0
movq %rax, %r12
movq 0x28(%r15), %rdi
movl $0x28, %esi
callq 0x3cb4
movq %rax, %r14
movq $0x0, (%rax)
movl $0x16, 0x8(%rax)
movq %r12, 0x10(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rax)
movq (%rbx), %rdi
callq 0x3686
movq %rax, (%rbx)
cmpb $0x7b, (%rax)
jne 0x5f9f
incq %rax
movq %rax, (%rbx)
movq %rax, %rdi
callq 0x3686
movq %rax, (%rbx)
cmpb $0x7d, (%rax)
je 0x5ed8
leaq 0x28(%r15), %r12
leaq 0x10(%rsp), %r13
movq %rsp, %rbp
movq %r13, %rdi
movq %rax, %rsi
callq 0x3700
cmpl $0x0, 0x1c(%rsp)
je 0x5d6f
movq (%rbx), %rdi
callq 0x3686
movq %rax, (%rbx)
xorl %ebp, %ebp
cmpb $0x7b, (%rax)
sete %bpl
leaq 0x76c0(%rip), %rax      # 0xd3f8
movq (%rax), %rcx
leaq 0x76be(%rip), %rax      # 0xd400
movq (%rax), %r8
movq %r15, %rdi
movq %rbx, %rsi
leaq 0x281e(%rip), %rdx      # 0x8570
callq 0x63dc
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
movl %ebp, %ecx
movq %rsp, %rbp
callq 0x6390
jmp 0x5ec4
movq 0x10(%rsp), %rax
leaq 0x767d(%rip), %rcx      # 0xd3f8
cmpq (%rcx), %rax
je 0x5db8
leaq 0x7679(%rip), %rcx      # 0xd400
cmpq (%rcx), %rax
jne 0x5d1d
movslq 0x18(%rsp), %rax
addq %rax, (%rbx)
movq %r12, %rdi
movq %r14, %rsi
callq 0x632e
movq (%rbx), %rdi
callq 0x3686
movq %rax, (%rbx)
cmpb $0x3a, (%rax)
je 0x5ebe
jmp 0x5f23
movslq 0x18(%rsp), %rdi
addq (%rbx), %rdi
movq %rdi, (%rbx)
callq 0x3686
movq %rax, (%rbx)
movq %rbp, %rdi
movq %rax, %rsi
callq 0x3700
movl 0xc(%rsp), %eax
movl %eax, %ecx
andl $-0x2, %ecx
cmpl $0x4, %ecx
jne 0x5dff
movq %r15, %rdi
movq %rbp, %rsi
callq 0x519c
movq %rax, %rdx
movslq 0x8(%rsp), %rax
addq %rax, (%rbx)
jmp 0x5ea3
cmpl $0x1, %eax
jne 0x5f42
movq (%rsp), %rax
leaq 0x74bd(%rip), %rcx      # 0xd2d0
cmpq (%rcx), %rax
leaq 0x28(%rsp), %rbp
jne 0x5f61
movslq 0x8(%rsp), %rdi
addq (%rbx), %rdi
movq %rdi, (%rbx)
callq 0x3686
movq %rax, (%rbx)
movq %rbp, %rdi
movq %rax, %rsi
callq 0x3700
movl 0x34(%rsp), %eax
andl $-0x2, %eax
cmpl $0x4, %eax
jne 0x5f80
leaq 0x747a(%rip), %rax      # 0xd2d0
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0x519c
movq %rax, %rbp
movq 0x28(%r15), %rdi
movl $0x20, %esi
callq 0x3cb4
movq %rax, %rdx
movq $0x0, (%rax)
movl $0x6, 0x8(%rax)
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rdx)
movq %rbp, 0x18(%rdx)
movslq 0x30(%rsp), %rax
addq %rax, (%rbx)
movq %rsp, %rbp
movq %r12, %rdi
movq %r14, %rsi
callq 0x62b8
movq (%rbx), %rdi
callq 0x3686
movq %rax, (%rbx)
cmpb $0x3a, (%rax)
jne 0x5f04
incq %rax
movq %rax, (%rbx)
movq (%rbx), %rdi
callq 0x3686
movq %rax, (%rbx)
cmpb $0x7d, (%rax)
jne 0x5d0b
movq %rax, %rdi
callq 0x3686
movq %rax, (%rbx)
cmpb $0x7d, (%rax)
jne 0x5fbe
incq %rax
movq %rax, (%rbx)
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x29f3(%rip), %rdi      # 0x88fe
leaq 0x22e5(%rip), %rsi      # 0x81f7
leaq 0x2919(%rip), %rcx      # 0x8832
movl $0x1ee, %edx            # imm = 0x1EE
callq 0x2100
leaq 0x29d4(%rip), %rdi      # 0x88fe
leaq 0x22c6(%rip), %rsi      # 0x81f7
leaq 0x28fa(%rip), %rcx      # 0x8832
movl $0x1f5, %edx            # imm = 0x1F5
callq 0x2100
leaq 0x2979(%rip), %rdi      # 0x88c2
leaq 0x22a7(%rip), %rsi      # 0x81f7
leaq 0x28db(%rip), %rcx      # 0x8832
movl $0x1e3, %edx            # imm = 0x1E3
callq 0x2100
leaq 0x2971(%rip), %rdi      # 0x88d9
leaq 0x2288(%rip), %rsi      # 0x81f7
leaq 0x28bc(%rip), %rcx      # 0x8832
movl $0x1e4, %edx            # imm = 0x1E4
callq 0x2100
leaq 0x2965(%rip), %rdi      # 0x88ec
leaq 0x2269(%rip), %rsi      # 0x81f7
leaq 0x289d(%rip), %rcx      # 0x8832
movl $0x1e8, %edx            # imm = 0x1E8
callq 0x2100
leaq 0x2533(%rip), %rdi      # 0x84d9
leaq 0x224a(%rip), %rsi      # 0x81f7
leaq 0x287e(%rip), %rcx      # 0x8832
movl $0x1d2, %edx            # imm = 0x1D2
callq 0x2100
leaq 0x25ae(%rip), %rdi      # 0x8573
leaq 0x222b(%rip), %rsi      # 0x81f7
leaq 0x285f(%rip), %rcx      # 0x8832
movl $0x201, %edx            # imm = 0x201
callq 0x2100
nop