// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/common/type.c
// Function: subtilis_type_section_new
subtilis_type_section_t *
subtilis_type_section_new(const subtilis_type_t *rtype, size_t num_parameters,
			  const subtilis_type_t *parameters,
			  subtilis_check_args_t *check_args,
			  subtilis_error_t *err)

{
	size_t i;
	subtilis_type_t *ftype;
	subtilis_type_section_t *stype = malloc(sizeof(*stype));

	if (!stype) {
		subtilis_error_set_oom(err);
		return NULL;
	}

	stype->ref_count = 1;

	ftype = &stype->type;
	ftype->type = SUBTILIS_TYPE_FN;
	ftype->params.fn.ret_val = calloc(1, sizeof(*ftype->params.fn.ret_val));
	if (!ftype->params.fn.ret_val) {
		subtilis_error_set_oom(err);
		goto on_error;
	}
	ftype->params.fn.ret_val->type = SUBTILIS_TYPE_VOID;
	subtilis_type_init_copy(ftype->params.fn.ret_val, rtype, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto on_error;
	ftype->params.fn.num_params = num_parameters;
	for (i = 0; i < num_parameters; i++) {
		ftype->params.fn.params[i] =
		    calloc(1, sizeof(*ftype->params.fn.params[i]));
		if (!ftype->params.fn.params[i]) {
			subtilis_error_set_oom(err);
			goto on_error;
		}
		ftype->params.fn.params[i]->type = SUBTILIS_TYPE_VOID;

		subtilis_type_init_copy(ftype->params.fn.params[i],
					&parameters[i], err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto on_error;
	}
	stype->check_args = check_args;
	stype->int_regs = 0;
	stype->fp_regs = 0;

	for (i = 0; i < ftype->params.fn.num_params; i++) {
		switch (ftype->params.fn.params[i]->type) {
		case SUBTILIS_TYPE_INTEGER:
		case SUBTILIS_TYPE_BYTE:
		case SUBTILIS_TYPE_STRING:
		case SUBTILIS_TYPE_ARRAY_REAL:
		case SUBTILIS_TYPE_ARRAY_INTEGER:
		case SUBTILIS_TYPE_ARRAY_STRING:
		case SUBTILIS_TYPE_ARRAY_BYTE:
		case SUBTILIS_TYPE_ARRAY_FN:
		case SUBTILIS_TYPE_ARRAY_REC:
		case SUBTILIS_TYPE_VECTOR_REAL:
		case SUBTILIS_TYPE_VECTOR_INTEGER:
		case SUBTILIS_TYPE_VECTOR_STRING:
		case SUBTILIS_TYPE_VECTOR_BYTE:
		case SUBTILIS_TYPE_VECTOR_FN:
		case SUBTILIS_TYPE_VECTOR_REC:
		case SUBTILIS_TYPE_FN:
		case SUBTILIS_TYPE_REC:
			stype->int_regs++;
			break;
		case SUBTILIS_TYPE_REAL:
			stype->fp_regs++;
			break;
		default:
			subtilis_error_set_assertion_failed(err);
			goto on_error;
		}
	}

	return stype;

on_error:

	free(stype);
	return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %r14
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbp
movl $0x168, %edi            # imm = 0x168
callq 0x121d0
testq %rax, %rax
je 0x2f3c8
movq %rax, %rbx
movq $0x1, 0x150(%rax)
movl $0x9, (%rax)
movl $0x1, %edi
movl $0x148, %esi            # imm = 0x148
callq 0x12150
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x2f3e3
movl $0x8, (%rax)
movq %rax, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x2f457
cmpl $0x0, (%r14)
jne 0x2f3fc
movq %r13, 0x10(%rbx)
testq %r13, %r13
je 0x2f418
xorl %ebp, %ebp
movl $0x1, %edi
movl $0x148, %esi            # imm = 0x148
callq 0x12150
movq %rax, 0x18(%rbx,%rbp,8)
testq %rax, %rax
je 0x2f42b
movl $0x8, (%rax)
movq %rax, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2f457
cmpl $0x0, (%r14)
jne 0x2f3fc
incq %rbp
addq $0x148, %r12            # imm = 0x148
cmpq %rbp, %r13
jne 0x2f30e
movq 0x10(%rbx), %rax
movq %r15, 0x148(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x158(%rbx)
testq %rax, %rax
je 0x2f406
movq %rbx, %rcx
addq $0x158, %rcx            # imm = 0x158
xorl %edx, %edx
xorl %esi, %esi
xorl %edi, %edi
movq 0x18(%rbx,%rdi,8), %r8
movl (%r8), %r8d
leal -0x9(%r8), %r9d
cmpl $0xe, %r9d
jae 0x2f3a8
incq %rdx
movq %rdx, (%rcx)
incq %rdi
cmpq %rax, %rdi
jb 0x2f386
jmp 0x2f406
leal -0x5(%r8), %r9d
cmpl $0x3, %r9d
jb 0x2f398
cmpl $0x4, %r8d
jne 0x2f441
incq %rsi
movq %rsi, 0x160(%rbx)
jmp 0x2f39e
leaq 0x45cf9(%rip), %rdx     # 0x750c8
movq %r14, %rdi
movl $0x1, %esi
movl $0xca, %ecx
callq 0x145a4
jmp 0x2f404
leaq 0x45cde(%rip), %rdx     # 0x750c8
movq %r14, %rdi
movl $0x1, %esi
movl $0xd4, %ecx
callq 0x145a4
movq %rbx, %rdi
callq 0x122c0
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, 0x148(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x158(%rbx)
jmp 0x2f406
leaq 0x45c96(%rip), %rdx     # 0x750c8
movq %r14, %rdi
movl $0x1, %esi
movl $0xe0, %ecx
jmp 0x2f3f7
leaq 0x45c80(%rip), %rdx     # 0x750c8
movq %r14, %rdi
movl $0xf, %esi
movl $0x107, %ecx            # imm = 0x107
jmp 0x2f3f7