// File: /workspace/github_c_makefile_star2_O0/hughbarney[P]zepl/lisp.c
// Function: newEnv
Object *newEnv(Object ** func, Object ** vals, GC_PARAM)
{
	Object *object = newObject(TYPE_ENV, GC_ROOTS);

	if ((*func) == nil)
		object->parent = object->vars = object->vals = nil;
	else {
		Object *param = (*func)->params, *val = *vals;

		for (int nArgs = 0;; param = param->cdr, val = val->cdr, ++nArgs) {
			if (param == nil && val == nil)
				break;
			else if (param != nil && param->type == TYPE_SYMBOL)
				break;
			else if (val != nil && val->type != TYPE_CONS)
				exceptionWithObject(val, "is not a list");
			else if (param == nil && val != nil)
				exceptionWithObject(*func, "expects at most %d arguments", nArgs);
			else if (param != nil && val == nil) {
				for (; param->type == TYPE_CONS; param = param->cdr, ++nArgs);
				exceptionWithObject(*func, "expects at least %d arguments", nArgs);
			}
		}

		object->parent = (*func)->env;
		object->vars = (*func)->params;
		object->vals = *vals;
	}

	return object;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rsi
movl $0x7, %edi
callq 0x5990
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
cmpq 0x910c(%rip), %rax      # 0xf220
jne 0x613a
movq 0x9103(%rip), %rcx      # 0xf220
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x62aa
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x28(%rbp), %rax
cmpq 0x90ba(%rip), %rax      # 0xf220
jne 0x617a
movq -0x30(%rbp), %rax
cmpq 0x90ad(%rip), %rax      # 0xf220
jne 0x617a
jmp 0x6275
movq -0x28(%rbp), %rax
cmpq 0x909b(%rip), %rax      # 0xf220
je 0x6195
movq -0x28(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x6195
jmp 0x6275
movq -0x30(%rbp), %rax
cmpq 0x9080(%rip), %rax      # 0xf220
je 0x61bd
movq -0x30(%rbp), %rax
cmpl $0x3, (%rax)
je 0x61bd
movq -0x30(%rbp), %rdi
leaq 0x5379(%rip), %rsi      # 0xb52f
movb $0x0, %al
callq 0x50e0
movq -0x28(%rbp), %rax
cmpq 0x9058(%rip), %rax      # 0xf220
jne 0x61ef
movq -0x30(%rbp), %rax
cmpq 0x904b(%rip), %rax      # 0xf220
je 0x61ef
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movl -0x34(%rbp), %edx
leaq 0x5355(%rip), %rsi      # 0xb53d
movb $0x0, %al
callq 0x50e0
movq -0x28(%rbp), %rax
cmpq 0x9026(%rip), %rax      # 0xf220
je 0x6245
movq -0x30(%rbp), %rax
cmpq 0x9019(%rip), %rax      # 0xf220
jne 0x6245
jmp 0x620b
movq -0x28(%rbp), %rax
cmpl $0x3, (%rax)
jne 0x622d
jmp 0x6216
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x620b
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movl -0x34(%rbp), %edx
leaq 0x531c(%rip), %rsi      # 0xb55a
movb $0x0, %al
callq 0x50e0
jmp 0x6247
jmp 0x6249
jmp 0x624b
jmp 0x624d
jmp 0x624f
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x615b
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)