// File: /workspace/github_cpp_makefile_star2_O3/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 0x3704
movl 0xc(%r15), %eax
cmpl $0x6, %eax
je 0x5631
cmpl $0x2, %eax
jne 0x574c
movslq 0x8(%rsp), %rax
addq %rax, (%rbx)
movq (%rsp), %rsi
jmp 0x5648
movq (%rsp), %rax
cmpb $0x28, (%rax)
jne 0x574c
movq $0x0, (%rsp)
xorl %esi, %esi
leaq 0x28(%r14), %r12
movq %r12, %rdi
callq 0x5fd2
movq %rax, %r15
movq (%rbx), %rdi
callq 0x3692
movq %rax, (%rbx)
cmpb $0x28, (%rax)
jne 0x576b
incq %rax
movq %rax, (%rbx)
movq %rax, %rdi
callq 0x3692
movq %rax, (%rbx)
cmpb $0x29, (%rax)
je 0x56e9
leaq 0x10(%rsp), %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0x3704
cmpl $0x2, 0x1c(%rsp)
jne 0x570e
movslq 0x18(%rsp), %rax
addq %rax, (%rbx)
movq 0x10(%rsp), %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x602e
movq (%rbx), %rdi
callq 0x3692
movq %rax, (%rbx)
movzbl (%rax), %ecx
cmpl $0x2c, %ecx
jne 0x56db
incq %rax
movq %rax, (%rbx)
movq %rax, %rdi
callq 0x3692
movq %rax, (%rbx)
cmpb $0x29, (%rax)
jne 0x5686
jmp 0x56e9
cmpl $0x29, %ecx
jne 0x572d
cmpb $0x29, (%rax)
jne 0x578a
incq %rax
movq %rax, (%rbx)
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x609e
movq %r15, %rax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x2da6(%rip), %rdi      # 0x84bb
leaq 0x2adb(%rip), %rsi      # 0x81f7
leaq 0x2cfa(%rip), %rcx      # 0x841d
movl $0x16a, %edx            # imm = 0x16A
callq 0x2100
leaq 0x3374(%rip), %rdi      # 0x8aa8
leaq 0x2abc(%rip), %rsi      # 0x81f7
leaq 0x2cdb(%rip), %rcx      # 0x841d
movl $0x173, %edx            # imm = 0x173
callq 0x2100
leaq 0x2c9d(%rip), %rdi      # 0x83f0
leaq 0x2a9d(%rip), %rsi      # 0x81f7
leaq 0x2cbc(%rip), %rcx      # 0x841d
movl $0x15f, %edx            # imm = 0x15F
callq 0x2100
leaq 0x2d3d(%rip), %rdi      # 0x84af
leaq 0x2a7e(%rip), %rsi      # 0x81f7
leaq 0x2c9d(%rip), %rcx      # 0x841d
movl $0x164, %edx            # imm = 0x164
callq 0x2100
leaq 0x2d3c(%rip), %rdi      # 0x84cd
leaq 0x2a5f(%rip), %rsi      # 0x81f7
leaq 0x2c7e(%rip), %rcx      # 0x841d
movl $0x175, %edx            # imm = 0x175
callq 0x2100
nop