// File: /workspace/github_cpp_makefile_star2_O1/lukewagner[P]asmjs2wasm/src/cashew/parser.h
// Function: cashew::Parser<asmjs_ast::Node*, Builder>::parseFunction(cashew::Parser<asmjs_ast::Node*, Builder>::Frag&, char*&, char const*)
NodeRef parseFunction(Frag& frag, char*& src, const char* seps) {
    Frag name(src);
    if (name.type == IDENT) {
      src += name.size;
    } else {
      assert(name.type == SEPARATOR && name.str[0] == '(');
      name.str = IString();
    }
    NodeRef ret = builder.makeFunction(name.str);
    src = skipSpace(src);
    assert(*src == '(');
    src++;
    while (1) {
      src = skipSpace(src);
      if (*src == ')') break;
      Frag arg(src);
      assert(arg.type == IDENT);
      src += arg.size;
      builder.appendArgumentToFunction(ret, arg.str);
      src = skipSpace(src);
      if (*src && *src == ')') break;
      if (*src && *src == ',') {
        src++;
        continue;
      }
      assert(0);
    }
    assert(*src == ')');
    src++;
    parseBracketedBlock(src, ret);
    // TODO: parse expression?
    return ret;
  }

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdx, %rbx
movq %rdi, %r14
movq (%rdx), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x3700
movl 0xc(%r15), %eax
cmpl $0x6, %eax
je 0x563d
cmpl $0x2, %eax
jne 0x575d
movslq 0x8(%rsp), %rax
addq %rax, (%rbx)
jmp 0x5652
movq (%rsp), %rax
cmpb $0x28, (%rax)
jne 0x575d
movq $0x0, (%rsp)
leaq 0x28(%r14), %r12
movq (%rsp), %rsi
movq %r12, %rdi
callq 0x5fde
movq %rax, %r15
movq (%rbx), %rdi
callq 0x3686
movq %rax, (%rbx)
cmpb $0x28, (%rax)
jne 0x577c
incq %rax
movq %rax, (%rbx)
movq %rax, %rdi
callq 0x3686
movq %rax, (%rbx)
cmpb $0x29, (%rax)
je 0x56ee
leaq 0x10(%rsp), %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0x3700
cmpl $0x2, 0x1c(%rsp)
jne 0x571f
movslq 0x18(%rsp), %rax
addq %rax, (%rbx)
movq 0x10(%rsp), %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x603a
movq (%rbx), %rdi
callq 0x3686
movq %rax, (%rbx)
movzbl (%rax), %ecx
cmpl $0x2c, %ecx
jne 0x56e9
incq %rax
movq %rax, (%rbx)
movq %rax, %rdi
callq 0x3686
movq %rax, (%rbx)
cmpb $0x29, (%rax)
jne 0x5694
jmp 0x56ee
cmpl $0x29, %ecx
jne 0x573e
movq (%rbx), %rax
cmpb $0x29, (%rax)
jne 0x579b
incq %rax
movq %rax, (%rbx)
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x60aa
movq %r15, %rax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x2d95(%rip), %rdi      # 0x84bb
leaq 0x2aca(%rip), %rsi      # 0x81f7
leaq 0x2ce9(%rip), %rcx      # 0x841d
movl $0x16a, %edx            # imm = 0x16A
callq 0x2100
leaq 0x3363(%rip), %rdi      # 0x8aa8
leaq 0x2aab(%rip), %rsi      # 0x81f7
leaq 0x2cca(%rip), %rcx      # 0x841d
movl $0x173, %edx            # imm = 0x173
callq 0x2100
leaq 0x2c8c(%rip), %rdi      # 0x83f0
leaq 0x2a8c(%rip), %rsi      # 0x81f7
leaq 0x2cab(%rip), %rcx      # 0x841d
movl $0x15f, %edx            # imm = 0x15F
callq 0x2100
leaq 0x2d2c(%rip), %rdi      # 0x84af
leaq 0x2a6d(%rip), %rsi      # 0x81f7
leaq 0x2c8c(%rip), %rcx      # 0x841d
movl $0x164, %edx            # imm = 0x164
callq 0x2100
leaq 0x2d2b(%rip), %rdi      # 0x84cd
leaq 0x2a4e(%rip), %rsi      # 0x81f7
leaq 0x2c6d(%rip), %rcx      # 0x841d
movl $0x175, %edx            # imm = 0x175
callq 0x2100