// File: /workspace/github_c_makefile_star2_O1/mattn[P]orelang/ore.c
// Function: ore_func_call
ore_value
ore_func_call(ore_context* ore, ore_value fn, int num_in, ore_value* args) {
  if ((fn.v.f.num_in != -1 && num_in < fn.v.f.num_in) || (fn.v.f.max_in != -1 && num_in > fn.v.f.max_in)) {
    fprintf(stderr, "number of arguments mismatch: %d for %d\n",
      num_in, fn.v.f.num_in);
    fprintf(stderr, "number of arguments mismatch: %d for %d\n",
      num_in, fn.v.f.max_in);
    ore->err = ORE_ERROR_EXCEPTION;
    return ore_value_nil();
  }

  ore_context* env = ore_new((ore_context*) fn.v.f.ore);
  mpc_ast_t* stmts = NULL;
  mpc_ast_t* f = fn.v.f.x.o;
  int n = 0, i;
  for (i = 2; i < f->children_num; i++) {
    if (is_a(f->children[i], "vararg")) {
      ore_array_t* a = kl_init(value);
      int j;
      for (j = 0; j < num_in; j++) {
        *kl_pushp(value, a) = args[j];
      }
      ore_define(env, f->children[i-1]->contents, ore_value_array_from_klist(ore, a));
    } else if (is_a(f->children[i], "ident")) {
      if (n < num_in)
        ore_define(env, f->children[i]->contents, args[n++]);
    } else if (is_a(f->children[i], "char")) {
      if (f->children[i]->contents[0] == '{') {
        i++;
        break;
      }
    }
  }
  for (; i < f->children_num; i++) {
    if (stmts == NULL && !is_a(f->children[i], "char")) {
      stmts = f->children[i];
    }
  }
  ore_value v = ore_value_nil();
  if (stmts) {
    v = ore_eval(env, stmts);
    if (env->err == ORE_ERROR_EXCEPTION)
      ore->err = env->err;
    char buf[64];
    sprintf(buf, "0x%p", env->env);
    ore_define(ore, buf, ore_value_env_from_context(env));
  }
  return v;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rcx, %r13
movl %edx, %r12d
movq %rsi, 0x30(%rsp)
movq %rdi, 0x40(%rsp)
leaq 0x150(%rsp), %r14
movl 0x10(%r14), %ecx
cmpl $-0x1, %ecx
setne %al
cmpl %edx, %ecx
setg %dl
testb %dl, %al
jne 0xdd72
movl 0x14(%r14), %eax
cmpl $-0x1, %eax
sete %dl
cmpl %r12d, %eax
setge %al
orb %dl, %al
je 0xdd72
movq %r12, 0x38(%rsp)
movq 0x8(%r14), %rdi
callq 0xd863
movq %rax, %rbp
movq 0x18(%r14), %r12
movl 0x28(%r12), %r14d
movl $0x2, %r15d
cmpl $0x3, %r14d
jl 0xdc85
movq 0x38(%rsp), %rax
leal -0x1(%rax), %ecx
incq %rcx
movq %rcx, 0x50(%rsp)
movl %eax, %eax
shlq $0x3, %rax
leaq (%rax,%rax,4), %rax
movq %rax, 0x78(%rsp)
movq $0x0, 0x48(%rsp)
movl $0x2, %r15d
movq %rbp, 0x60(%rsp)
movq %r12, 0x58(%rsp)
movq 0x30(%r12), %rax
movq %r15, 0x28(%rsp)
movq (%rax,%r15,8), %r15
movq (%r15), %rbx
movq %rbx, %rdi
leaq 0x70f5(%rip), %rsi      # 0x14b53
callq 0x2290
testq %rax, %rax
je 0xdaaf
movl $0x1, %edi
movl $0x20, %esi
callq 0x2140
movq %rax, %rbx
movl $0x1, %edi
movl $0x20, %esi
callq 0x2140
movq %rax, %r14
incq (%rax)
movq %rax, 0x10(%rbx)
movq 0x8(%rax), %rax
testq %rax, %rax
je 0xdb14
movq 0x18(%r14), %rcx
leaq -0x1(%rax), %rdx
movq %rdx, 0x8(%r14)
movq -0x8(%rcx,%rax,8), %rax
jmp 0xdb23
movq %rbx, %rdi
leaq 0x70a1(%rip), %rsi      # 0x14b5a
callq 0x2290
testq %rax, %rax
je 0xdc48
movq 0x48(%rsp), %rcx
cmpl 0x38(%rsp), %ecx
jge 0xdc6f
movq 0x8(%r15), %rsi
movslq %ecx, %rax
incl %ecx
movq %rcx, 0x48(%rsp)
leaq (%rax,%rax,4), %rax
movq 0x20(%r13,%rax,8), %rcx
movq %rcx, 0x20(%rsp)
movups (%r13,%rax,8), %xmm0
movups 0x10(%r13,%rax,8), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbp, %rdi
callq 0xd5d3
jmp 0xdc6f
movl $0x1, %edi
movl $0x30, %esi
callq 0x2140
movq 0x28(%rsp), %r15
movq %rax, 0x8(%rbx)
movq %rax, (%rbx)
movq $0x0, 0x28(%rax)
cmpl $0x0, 0x38(%rsp)
jle 0xdbf2
movq (%r14), %rax
movq %rax, 0x70(%rsp)
movq 0x8(%r14), %rbp
movq 0x8(%rbx), %r12
movq 0x18(%rbx), %rax
addq 0x50(%rsp), %rax
movq %rax, 0x68(%rsp)
xorl %r15d, %r15d
testq %rbp, %rbp
je 0xdb7e
movq 0x18(%r14), %rax
leaq -0x1(%rbp), %rcx
movq %rcx, 0x8(%r14)
movq -0x8(%rax,%rbp,8), %rax
movq %rcx, %rbp
jmp 0xdb8d
movl $0x1, %edi
movl $0x30, %esi
callq 0x2140
movq $0x0, 0x28(%rax)
movq %rax, 0x28(%r12)
movq %rax, 0x8(%rbx)
movq 0x20(%r13,%r15), %rcx
movq %rcx, 0x20(%r12)
movups (%r13,%r15), %xmm0
movups 0x10(%r13,%r15), %xmm1
movups %xmm1, 0x10(%r12)
movups %xmm0, (%r12)
addq $0x28, %r15
movq %rax, %r12
cmpq %r15, 0x78(%rsp)
jne 0xdb63
movq 0x70(%rsp), %rax
addq 0x50(%rsp), %rax
movq %rax, (%r14)
movq 0x68(%rsp), %rax
movq %rax, 0x18(%rbx)
movq 0x60(%rsp), %rbp
movq 0x58(%rsp), %r12
movq 0x28(%rsp), %r15
movq 0x30(%r12), %rax
movq -0x8(%rax,%r15,8), %rax
movq 0x8(%rax), %r14
leaq 0x80(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq %rbx, %rdx
callq 0xde8c
movq 0xa0(%rsp), %rax
movq %rax, 0x20(%rsp)
movups 0x80(%rsp), %xmm0
movups 0x90(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbp, %rdi
movq %r14, %rsi
callq 0xd5d3
jmp 0xdc74
movq %rbx, %rdi
leaq 0x68a6(%rip), %rsi      # 0x144f8
callq 0x2290
testq %rax, %rax
je 0xdc6f
movq 0x8(%r15), %rax
cmpb $0x7b, (%rax)
movq 0x28(%rsp), %r15
jne 0xdc74
jmp 0xddc9
movq 0x28(%rsp), %r15
incq %r15
movslq 0x28(%r12), %r14
cmpq %r14, %r15
jl 0xda43
cmpl %r14d, %r15d
jge 0xdcc5
movq %r12, %r13
movl %r15d, %r15d
movl %r14d, %r12d
xorl %ebx, %ebx
leaq 0x685c(%rip), %r14      # 0x144f8
testq %rbx, %rbx
jne 0xdcbb
movq 0x30(%r13), %rax
movq (%rax,%r15,8), %rbx
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x2290
testq %rax, %rax
je 0xdcbb
xorl %ebx, %ebx
incq %r15
cmpq %r15, %r12
jne 0xdc9c
jmp 0xdcc7
xorl %ebx, %ebx
xorps %xmm0, %xmm0
movq 0x40(%rsp), %r15
movups %xmm0, 0x10(%r15)
movups %xmm0, (%r15)
movq $0x0, 0x20(%r15)
testq %rbx, %rbx
je 0xdd5d
movq %r15, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0xdee3
cmpl $0x1, 0x20(%rbp)
jne 0xdd05
movq 0x30(%rsp), %rax
movl $0x1, 0x20(%rax)
movq (%rbp), %rdx
leaq 0x6e50(%rip), %rsi      # 0x14b60
leaq 0xd0(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2240
leaq 0xa8(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0xce19
movq 0x20(%r14), %rax
movq %rax, 0x20(%rsp)
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0xd5d3
movq %r15, %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xe27f(%rip), %r15      # 0x1bff8
movq (%r15), %rdi
leaq 0x6da7(%rip), %rbx      # 0x14b2a
movq %rbx, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x2160
movq (%r15), %rdi
movl 0x14(%r14), %ecx
movq %rbx, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x2160
movq 0x30(%rsp), %rax
movl $0x1, 0x20(%rax)
xorps %xmm0, %xmm0
movq 0x40(%rsp), %rax
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movq $0x0, 0x20(%rax)
jmp 0xdd60
incl %r15d
jmp 0xdc85