// File: 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 %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rsi
leaq -0x30(%rbp), %rdi
callq 0x5f00
cmpl $0x2, -0x24(%rbp)
jne 0xb53b
movl -0x28(%rbp), %edx
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, (%rax)
jmp 0xb598
xorl %eax, %eax
cmpl $0x6, -0x24(%rbp)
movb %al, -0x69(%rbp)
jne 0xb55d
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
callq 0xc300
movsbl %al, %eax
cmpl $0x28, %eax
sete %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0xb566
jmp 0xb568
jmp 0xb587
leaq 0x9f94(%rip), %rdi      # 0x15503
leaq 0x9d91(%rip), %rsi      # 0x15307
movl $0x15f, %edx            # imm = 0x15F
leaq 0x9fae(%rip), %rcx      # 0x15530
callq 0x2130
leaq -0x38(%rbp), %rdi
callq 0x5cd0
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x68(%rbp), %rdi
addq $0x28, %rdi
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rsi
callq 0xc320
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x5d30
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x28, %eax
jne 0xb5dc
jmp 0xb5fb
leaq 0x9fdf(%rip), %rdi      # 0x155c2
leaq 0x9d1d(%rip), %rsi      # 0x15307
movl $0x164, %edx            # imm = 0x164
leaq 0x9f3a(%rip), %rcx      # 0x15530
callq 0x2130
movq -0x18(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x5d30
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x29, %eax
jne 0xb633
jmp 0xb71a
movq -0x18(%rbp), %rax
movq (%rax), %rsi
leaq -0x58(%rbp), %rdi
callq 0x5f00
cmpl $0x2, -0x4c(%rbp)
jne 0xb64b
jmp 0xb66a
leaq 0x9f7c(%rip), %rdi      # 0x155ce
leaq 0x9cae(%rip), %rsi      # 0x15307
movl $0x16a, %edx            # imm = 0x16A
leaq 0x9ecb(%rip), %rcx      # 0x15530
callq 0x2130
movq -0x68(%rbp), %rdi
movl -0x50(%rbp), %edx
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, (%rax)
addq $0x28, %rdi
movq -0x40(%rbp), %rsi
movq -0x58(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdx
callq 0xc390
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x5d30
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
cmpb $0x0, (%rax)
je 0xb6cd
movq -0x18(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x29, %eax
jne 0xb6cd
jmp 0xb71a
movq -0x18(%rbp), %rax
movq (%rax), %rax
cmpb $0x0, (%rax)
je 0xb6fb
movq -0x18(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x2c, %eax
jne 0xb6fb
movq -0x18(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
jmp 0xb609
leaq 0xa4b9(%rip), %rdi      # 0x15bbb
leaq 0x9bfe(%rip), %rsi      # 0x15307
movl $0x173, %edx            # imm = 0x173
leaq 0x9e1b(%rip), %rcx      # 0x15530
callq 0x2130
movq -0x18(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x29, %eax
jne 0xb72b
jmp 0xb74a
leaq 0x9eae(%rip), %rdi      # 0x155e0
leaq 0x9bce(%rip), %rsi      # 0x15307
movl $0x175, %edx            # imm = 0x175
leaq 0x9deb(%rip), %rcx      # 0x15530
callq 0x2130
movq -0x68(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0x18(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0xc400
movq -0x40(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)