// File: /workspace/github_c_makefile_star2_O2/mrkite[P]regs/docmaker/parser.cc
// Function: Parser::parseFunc(Symbol*, File*)
bool Parser::parseFunc(Symbol *s, File *f) {
  Function *func = new Function();
  s->kind = isFunction;
  s->asFunction = func;

  Token token;
  while ((token = f->token()).type == VAR) {
    Argument arg;
    if (!parseArgument(&arg, token, f)) {
      return false;
    }
    func->arguments.push_back(arg);
    token = f->token();
    if (!token.expect(",)")) {
      return false;
    }
    if (token.asSym == ')') {
      break;
    }
  }
  if (!token.expect(')')) {
    return false;
  }
  token = f->token();
  if (!token.expect(":;{")) {
    return false;
  }
  func->retType.symbol = nullptr;
  if (token.asSym == ':') {
    if (!parseRef(&func->retType, f)) {
      return false;
    }
    token = f->token();
    if (!token.expect(";{")) {
      return false;
    }
  }
  if (token.asSym == '{') {
    while ((token = f->token()).type == NUMBER) {
      func->signature.push_back(token.asNum);
      token = f->token();
      if (!token.expect(",}")) {
        return false;
      }
      if (token.asSym == '}') {
        break;
      }
    }
    if (!token.expect('}')) {
      return false;
    }
  }
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, 0x8(%rsp)
pushq $0x60
popq %rdi
callq 0x21d0
movq %rax, %r12
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, (%rax)
andq $0x0, 0x40(%rax)
movups %xmm0, 0x10(%rax)
orl $-0x1, 0x24(%rax)
addq $0x38, %rax
movq %rax, 0x28(%r12)
xorl %edx, %edx
movb %dl, 0x38(%r12)
andq $0x0, 0x58(%r12)
movups %xmm0, 0x48(%r12)
movl $0x6, 0x78(%r14)
movq %r12, 0x80(%r14)
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq 0x48(%r12), %rcx
movq %rcx, 0x10(%rsp)
movb %dl, (%rax)
movb %dl, 0x10(%rax)
andl $0x0, 0x14(%rax)
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %dl, (%rax)
leaq 0xc0(%rsp), %r13
leaq 0x18(%rsp), %rbp
leaq 0x70(%rsp), %r14
movq %r13, %rdi
movq %rbx, %rsi
callq 0x54d6
movq %rbp, %rdi
movq %r13, %rsi
callq 0x3e8e
movl (%rax), %r15d
movq %r13, %rdi
callq 0x3d0a
cmpl $0x7, %r15d
jne 0x34ec
leaq 0x80(%rsp), %rax
movq %rax, 0x70(%rsp)
andq $0x0, 0x78(%rsp)
xorl %eax, %eax
movb %al, 0x80(%rsp)
andq $0x0, 0x90(%rsp)
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
movq %rcx, 0x98(%rsp)
leaq 0xb0(%rsp), %rcx
movq %rcx, 0xa0(%rsp)
andq $0x0, 0xa8(%rsp)
movb %al, 0xb0(%rsp)
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x391c
testb %al, %al
je 0x365f
movq %r12, %rdi
movq %r14, %rsi
callq 0x3ed0
movq %r13, %rdi
movq %rbx, %rsi
callq 0x54d6
movq %rbp, %rdi
movq %r13, %rsi
callq 0x3e8e
movq %r13, %rdi
callq 0x3d0a
movq %rbp, %rdi
leaq 0x3c6b(%rip), %rsi      # 0x7133
callq 0x57b8
testb %al, %al
je 0x365f
movb 0x40(%rsp), %r15b
movq %r14, %rdi
callq 0x3efc
cmpb $0x29, %r15b
jne 0x33f8
leaq 0x18(%rsp), %rdi
pushq $0x29
popq %rsi
callq 0x5716
testb %al, %al
je 0x3669
leaq 0xc0(%rsp), %rdi
movq %rbx, %rsi
callq 0x54d6
leaq 0x18(%rsp), %r14
leaq 0xc0(%rsp), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x3e8e
movq %r13, %rdi
callq 0x3d0a
leaq 0x3bfe(%rip), %rsi      # 0x7136
movq %r14, %rdi
callq 0x57b8
testb %al, %al
je 0x3669
andq $0x0, 0x18(%r12)
movb 0x40(%rsp), %al
cmpb $0x3a, %al
jne 0x35bd
addq $0x18, %r12
movq 0x8(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x39a2
testb %al, %al
je 0x3669
leaq 0xc0(%rsp), %rdi
movq %rbx, %rsi
callq 0x54d6
leaq 0x18(%rsp), %r14
leaq 0xc0(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x3e8e
movq %r15, %rdi
callq 0x3d0a
leaq 0x3b8e(%rip), %rsi      # 0x7137
movq %r14, %rdi
callq 0x57b8
testb %al, %al
je 0x3669
movb 0x40(%rsp), %al
cmpb $0x7b, %al
jne 0x365b
leaq 0xc0(%rsp), %r14
leaq 0x18(%rsp), %r15
leaq 0x3b57(%rip), %r12      # 0x7130
movq %r14, %rdi
movq %rbx, %rsi
callq 0x54d6
movq %r15, %rdi
movq %r14, %rsi
callq 0x3e8e
movl (%rax), %ebp
movq %r14, %rdi
callq 0x3d0a
cmpl $0x2, %ebp
jne 0x364a
movl 0x44(%rsp), %eax
movl %eax, 0xc0(%rsp)
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x49d8
movq %r14, %rdi
movq %rbx, %rsi
callq 0x54d6
movq %r15, %rdi
movq %r14, %rsi
callq 0x3e8e
movq %r14, %rdi
callq 0x3d0a
movq %r15, %rdi
movq %r12, %rsi
callq 0x57b8
testb %al, %al
je 0x3669
cmpb $0x7d, 0x40(%rsp)
jne 0x35d9
leaq 0x18(%rsp), %rdi
pushq $0x7d
popq %rsi
callq 0x5716
testb %al, %al
je 0x3669
movb $0x1, %bl
jmp 0x366b
leaq 0x70(%rsp), %rdi
callq 0x3efc
xorl %ebx, %ebx
leaq 0x18(%rsp), %rdi
callq 0x3d0a
movl %ebx, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3699
jmp 0x3699
jmp 0x3699
jmp 0x3699
jmp 0x3699
jmp 0x3699
jmp 0x3699
jmp 0x369e
movq %rax, %rbx
jmp 0x36ab
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x3efc
leaq 0x18(%rsp), %rdi
callq 0x3d0a
movq %rbx, %rdi
callq 0x23a0
nop