// File: /workspace/github_cpp_makefile_star2_O2/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
leaq 0x28(%rdi), %r12
movq %rdx, %rsi
callq 0x5de0
movq %r12, %rdi
movq %rax, %rsi
callq 0x5f8e
movq %rax, %r14
movq (%rbx), %rdi
callq 0x3546
movq %rax, (%rbx)
cmpb $0x7b, (%rax)
jne 0x5b6f
movq %rax, %rdi
incq %rdi
movq %rdi, (%rbx)
leaq 0x8(%rsp), %rbp
callq 0x3546
movq %rax, (%rbx)
cmpb $0x7d, (%rax)
je 0x5aa8
movq %rbp, %r13
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x35cc
cmpl $0x0, 0x24(%rsp)
je 0x5964
movq (%rbx), %rdi
callq 0x3546
movq %rax, (%rbx)
xorl %ebp, %ebp
cmpb $0x7b, (%rax)
sete %bpl
leaq 0x8ac3(%rip), %rax      # 0xe3f0
movq (%rax), %rcx
leaq 0x8ac1(%rip), %rax      # 0xe3f8
movq (%rax), %r8
movq %r15, %rdi
movq %rbx, %rsi
leaq 0x2c29(%rip), %rdx      # 0x8570
callq 0x60be
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
movl %ebp, %ecx
callq 0x608c
movq (%rbx), %rdi
movq %r13, %rbp
jmp 0x58ea
movq 0x18(%rsp), %rax
leaq 0x8a80(%rip), %rcx      # 0xe3f0
cmpq (%rcx), %rax
je 0x59b9
leaq 0x8a7c(%rip), %rcx      # 0xe3f8
cmpq (%rcx), %rax
jne 0x5912
movslq 0x20(%rsp), %rax
addq %rax, (%rbx)
movq %r12, %rdi
movq %r14, %rsi
callq 0x603c
movq (%rbx), %rdi
callq 0x3546
movq %rax, (%rbx)
cmpb $0x3a, (%rax)
jne 0x5af3
movq %rax, %rdi
incq %rdi
movq %rdi, (%rbx)
movq %r13, %rbp
jmp 0x58ea
movslq 0x20(%rsp), %rdi
addq (%rbx), %rdi
movq %rdi, (%rbx)
callq 0x3546
movq %rax, (%rbx)
movq %r13, %rbp
movq %r13, %rdi
movq %rax, %rsi
callq 0x35cc
movl 0x14(%rsp), %eax
movl %eax, %ecx
andl $-0x2, %ecx
cmpl $0x4, %ecx
jne 0x59fd
movq %r15, %rdi
movq %rbp, %rsi
callq 0x4f40
movslq 0x10(%rsp), %rcx
addq %rcx, (%rbx)
jmp 0x5a7c
cmpl $0x1, %eax
jne 0x5b12
movq 0x8(%rsp), %rax
leaq 0x88b6(%rip), %rcx      # 0xe2c8
cmpq (%rcx), %rax
leaq 0x28(%rsp), %rbp
jne 0x5b31
movslq 0x10(%rsp), %rdi
addq (%rbx), %rdi
movq %rdi, (%rbx)
callq 0x3546
movq %rax, (%rbx)
movq %rbp, %rdi
movq %rax, %rsi
callq 0x35cc
movl 0x34(%rsp), %eax
andl $-0x2, %eax
cmpl $0x4, %eax
jne 0x5b50
movq %rbp, %rsi
leaq 0x8870(%rip), %rax      # 0xe2c8
movq (%rax), %rbp
movq %r15, %rdi
callq 0x4f40
movq %r12, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x5fb6
movslq 0x30(%rsp), %rcx
addq %rcx, (%rbx)
movq %r13, %rbp
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x5fe6
movq (%rbx), %rdi
callq 0x3546
movq %rax, (%rbx)
cmpb $0x3a, (%rax)
jne 0x5ad4
movq %rax, %rdi
incq %rdi
movq %rdi, (%rbx)
jmp 0x58ea
movq %rax, %rdi
callq 0x3546
movq %rax, (%rbx)
cmpb $0x7d, (%rax)
jne 0x5b8e
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 0x2e23(%rip), %rdi      # 0x88fe
leaq 0x2715(%rip), %rsi      # 0x81f7
leaq 0x2d49(%rip), %rcx      # 0x8832
movl $0x1ee, %edx            # imm = 0x1EE
callq 0x2120
leaq 0x2e04(%rip), %rdi      # 0x88fe
leaq 0x26f6(%rip), %rsi      # 0x81f7
leaq 0x2d2a(%rip), %rcx      # 0x8832
movl $0x1f5, %edx            # imm = 0x1F5
callq 0x2120
leaq 0x2da9(%rip), %rdi      # 0x88c2
leaq 0x26d7(%rip), %rsi      # 0x81f7
leaq 0x2d0b(%rip), %rcx      # 0x8832
movl $0x1e3, %edx            # imm = 0x1E3
callq 0x2120
leaq 0x2da1(%rip), %rdi      # 0x88d9
leaq 0x26b8(%rip), %rsi      # 0x81f7
leaq 0x2cec(%rip), %rcx      # 0x8832
movl $0x1e4, %edx            # imm = 0x1E4
callq 0x2120
leaq 0x2d95(%rip), %rdi      # 0x88ec
leaq 0x2699(%rip), %rsi      # 0x81f7
leaq 0x2ccd(%rip), %rcx      # 0x8832
movl $0x1e8, %edx            # imm = 0x1E8
callq 0x2120
leaq 0x2963(%rip), %rdi      # 0x84d9
leaq 0x267a(%rip), %rsi      # 0x81f7
leaq 0x2cae(%rip), %rcx      # 0x8832
movl $0x1d2, %edx            # imm = 0x1D2
callq 0x2120
leaq 0x29de(%rip), %rdi      # 0x8573
leaq 0x265b(%rip), %rsi      # 0x81f7
leaq 0x2c8f(%rip), %rcx      # 0x8832
movl $0x201, %edx            # imm = 0x201
callq 0x2120
nop